Giter Club home page Giter Club logo

Comments (10)

mtasaka avatar mtasaka commented on June 9, 2024 1

Fow now, I've forwarded to ruby for Reline behavior: https://bugs.ruby-lang.org/issues/20052

from aruba.

tompng avatar tompng commented on June 9, 2024 1

As a workaround, adding gem 'readline-ext' like rails/rails might solve this. rails/rails#48183
require 'readline' tries to require real readline and fallbacks to reline in both ruby 3.2 and 3.3.
Ruby 3.3 does not bundle readline-ext anymore.

from aruba.

mtasaka avatar mtasaka commented on June 9, 2024

ruby3.3 is going to be released within one month. Can you enable ruby3.3 on github CI and debug this issue?

from aruba.

mvz avatar mvz commented on June 9, 2024

Hi @mtasaka thanks for the reminder. I'll look into it.

from aruba.

mvz avatar mvz commented on June 9, 2024

I have debugged this issue and the source of the difference is that require "readline" loads Reline in Ruby 3.3, and 'real' Readline in Ruby 3.2.

Reline behaves oddly when output is not a tty. This can be demonstrated without pry and without using Ruby 3.3 by running irb piping to tee:

$ irb | tee irb.log
irb(main):001> foo = 1
irb(main):001> firb(main):001> foirb(main):001> fooirb(main):001> foo irb(main):001> foo =irb(main):001> foo = irb(main):001> foo = 1=> 1
irb(main):002> foo
irb(main):002> firb(main):002> foirb(main):002> foo=> 1
irb(main):003> exit
irb(main):003> eirb(main):003> exirb(main):003> exiirb(main):003> exit %                                                                                                                                             

Or even simpler:

$ echo 'foo' | ruby -e 'require "reline"; puts Reline.readline(">")' | tee bar.log
>>>f>f>fo>fo>foo>foofoo

from aruba.

mvz avatar mvz commented on June 9, 2024

Summarizing, this issue with Reline affects the test suite because

  • pry uses Reline by default with Ruby 3.3
  • pry uses a non-empty prompt
  • Reline has the issue described above when output is not a tty
  • Aruba's SpawnProcess creates an output stream for the process that is not a tty

Options for Aruba are:

  • Change the test suite to use irb. For some reason (not yet clear to me), irb won't show any prompt when run this way, which means this problem doesn't occur
  • Change Aruba's SpawnProcess runner so the spawned process is a tty. I've looked into this and PTY.open might play a role in this but I don't yet see a solution that doesn't involve manually reading from the resulting output, which we now avoid by just passing an open file handle pointing to an open Tempfile.
  • Wait for the Reline bug (?) to be fixed. I'm not keen on this option because Aruba should be ready to test with Ruby 3.3 as soon as it's released

I lean toward the first option, which means

  • Updating the test suite
  • Documenting that Aruba will run processes under test with output that is not a tty
  • Opening a new ticket to add a feature to make the output streams ttys, either optionally or always

from aruba.

mvz avatar mvz commented on June 9, 2024

Thanks @tompng. I looked that pull request and its comments and another work-around was merged later, which uses Reline but sets TERM=dumb: rails/rails#48369. I will try and see if that works for Aruba as well.

from aruba.

tompng avatar tompng commented on June 9, 2024

Some other workaround I found is to

Ease the assertion condition from contain to match

Then the output should match:
"""
\[1\] pry\(main\)> input1\n?=> output2
"""
And the output should match:
"""
\[2\] pry\(main\)> input2\n?=> output2
"""

Or use a dummy readline for test

Given an executable named "bin/aruba-test-cli" with:
"""
module DummyReadline
  def self.readline(prompt)
    gets.tap { |l| puts prompt + l }
  end
end
require 'pry'
Pry.start(self, input: DummyReadline)
"""

from aruba.

mvz avatar mvz commented on June 9, 2024

Thanks @tompng I'll try those.

from aruba.

mvz avatar mvz commented on June 9, 2024

With #914 merged, Aruba is ready for Ruby 3.3. Next steps are adding documentation that stdout and stderr of our SpawnProcess are not ttys, and then see if we can use PTY to present a tty.

from aruba.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.