From bbd20445ea349acd9b12343286d8bdcaa633e9fc Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Fri, 4 Aug 2023 18:13:51 +0100 Subject: [PATCH] Store integration tests' envs in an ivar (#668) --- test/irb/helper.rb | 8 +++----- test/irb/test_debug_cmd.rb | 10 ++++------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/test/irb/helper.rb b/test/irb/helper.rb index 650b95d8f..2372305d6 100644 --- a/test/irb/helper.rb +++ b/test/irb/helper.rb @@ -87,6 +87,8 @@ def setup unless defined?(PTY) omit "Integration tests require PTY." end + + @envs = {} end def run_ruby_file(&block) @@ -98,7 +100,7 @@ def run_ruby_file(&block) yield - PTY.spawn(integration_envs.merge("TERM" => "dumb"), *cmd) do |read, write, pid| + PTY.spawn(@envs.merge("TERM" => "dumb"), *cmd) do |read, write, pid| Timeout.timeout(TIMEOUT_SEC) do while line = safe_gets(read) lines << line @@ -178,9 +180,5 @@ def write_ruby(program) @ruby_file.write(program) @ruby_file.close end - - def integration_envs - {} - end end end diff --git a/test/irb/test_debug_cmd.rb b/test/irb/test_debug_cmd.rb index aa0321b66..d4cd87c75 100644 --- a/test/irb/test_debug_cmd.rb +++ b/test/irb/test_debug_cmd.rb @@ -8,6 +8,8 @@ module TestIRB class DebugCommandTest < IntegrationTestCase def setup + super + if ruby_core? omit "This test works only under ruby/irb" end @@ -15,6 +17,8 @@ def setup if RUBY_ENGINE == 'truffleruby' omit "This test runs with ruby/debug, which doesn't work with truffleruby" end + + @envs.merge!("NO_COLOR" => "true", "RUBY_DEBUG_HISTORY_FILE" => '') end def test_backtrace @@ -189,11 +193,5 @@ def test_catch assert_match(/\(rdbg:irb\) catch/, output) assert_match(/Stop by #0 BP - Catch "ZeroDivisionError"/, output) end - - private - - def integration_envs - { "NO_COLOR" => "true", "RUBY_DEBUG_HISTORY_FILE" => '' } - end end end