diff --git a/lib/irb/context.rb b/lib/irb/context.rb index 1d9b48e2a..9130ae588 100644 --- a/lib/irb/context.rb +++ b/lib/irb/context.rb @@ -152,6 +152,7 @@ def initialize(irb, workspace = nil, input_method = nil) end private def term_interactive? + return true if ENV['TEST_IRB_FORCE_INTERACTIVE'] STDIN.tty? && ENV['TERM'] != 'dumb' end diff --git a/test/irb/helper.rb b/test/irb/helper.rb index 1614b42ad..2acc465a7 100644 --- a/test/irb/helper.rb +++ b/test/irb/helper.rb @@ -121,7 +121,9 @@ def run_ruby_file(&block) @envs["XDG_CONFIG_HOME"] ||= tmp_dir @envs["IRBRC"] = nil unless @envs.key?("IRBRC") - PTY.spawn(@envs.merge("TERM" => "dumb"), *cmd) do |read, write, pid| + envs_for_spawn = @envs.merge('TERM' => 'dumb', 'TEST_IRB_FORCE_INTERACTIVE' => 'true') + + PTY.spawn(envs_for_spawn, *cmd) do |read, write, pid| Timeout.timeout(TIMEOUT_SEC) do while line = safe_gets(read) lines << line