[ruby/irb] Improve debug command tests

(https://github.com/ruby/irb/pull/594)

* Use require_relative for envutil.rb

Requiring test helper files with `require_relative` allows running the tests
with `ruby -Itest test/irb/test_debug_cmd.rb` without having to set up
the load path.

* Replace reline hack with TERM=dumb
This commit is contained in:
Stan Lo 2023-06-01 21:10:08 +01:00 committed by git
parent 39968112f5
commit 2d2893f206

View File

@ -8,8 +8,8 @@ end
require "tempfile"
require "tmpdir"
require "envutil"
require_relative "../lib/envutil"
require_relative "helper"
module TestIRB
@ -210,19 +210,13 @@ module TestIRB
def run_ruby_file(&block)
cmd = [EnvUtil.rubybin, "-I", LIB, @ruby_file.to_path]
tmp_dir = Dir.mktmpdir
rc_file = File.open(File.join(tmp_dir, ".irbrc"), "w+")
rc_file.write(<<~RUBY)
IRB.conf[:USE_SINGLELINE] = true
Reline.const_set(:IOGate, Reline::GeneralIO)
RUBY
rc_file.close
@commands = []
lines = []
yield
PTY.spawn(IRB_AND_DEBUGGER_OPTIONS.merge("IRBRC" => rc_file.to_path), *cmd) do |read, write, pid|
PTY.spawn(IRB_AND_DEBUGGER_OPTIONS.merge("TERM" => "dumb"), *cmd) do |read, write, pid|
Timeout.timeout(TIMEOUT_SEC) do
while line = safe_gets(read)
lines << line