[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:
parent
39968112f5
commit
2d2893f206
@ -8,8 +8,8 @@ end
|
|||||||
|
|
||||||
require "tempfile"
|
require "tempfile"
|
||||||
require "tmpdir"
|
require "tmpdir"
|
||||||
require "envutil"
|
|
||||||
|
|
||||||
|
require_relative "../lib/envutil"
|
||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module TestIRB
|
module TestIRB
|
||||||
@ -210,19 +210,13 @@ module TestIRB
|
|||||||
def run_ruby_file(&block)
|
def run_ruby_file(&block)
|
||||||
cmd = [EnvUtil.rubybin, "-I", LIB, @ruby_file.to_path]
|
cmd = [EnvUtil.rubybin, "-I", LIB, @ruby_file.to_path]
|
||||||
tmp_dir = Dir.mktmpdir
|
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 = []
|
@commands = []
|
||||||
lines = []
|
lines = []
|
||||||
|
|
||||||
yield
|
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
|
Timeout.timeout(TIMEOUT_SEC) do
|
||||||
while line = safe_gets(read)
|
while line = safe_gets(read)
|
||||||
lines << line
|
lines << line
|
||||||
|
Loading…
x
Reference in New Issue
Block a user