From 1edfbf18249f6993a500ed069e9193358b49d578 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Fri, 22 Mar 2024 19:34:56 +0200 Subject: [PATCH] Add special env for testing See discussion in #907. --- lib/irb/context.rb | 1 + test/irb/helper.rb | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) 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