Skip to content

Commit 3685859

Browse files
st0012ko1
authored andcommitted
Improve RUBYOPT's handling in tests
When debugging the issue related to ruby/irb#919, I noticed that debugger tests don't respect the IRB version I specified in the Gemfile. This is because console tests force override the RUBYOPT env, which will remove the `-rbundler/setup` injected by bundler. Further more, if tests use `run_rdbg` with the `rubyopt` option, the RUBYOPT will be overridden yet again. So in this commit I did 2 improvements: 1. `run_rdbg` should append instead of override RUBYOPT 2. If tests are executed with bundler, we also run the debugger in PTY process with bundler by appending `-rbundler/setup` to RUBYOPT
1 parent ee59c85 commit 3685859

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Diff for: test/support/console_test_case.rb

+7-6
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,12 @@ def prepare_test_environment(program, test_steps, &block)
225225
@scenario = []
226226
test_steps.call
227227
@scenario.freeze
228-
inject_lib_to_load_path
228+
229+
ENV['RUBYOPT'] = "-I #{__dir__}/../../lib"
230+
231+
if ENV.key?('BUNDLE_GEMFILE')
232+
ENV["RUBYOPT"] += " -rbundler/setup"
233+
end
229234

230235
block.call
231236

@@ -283,7 +288,7 @@ def run_rdbg program, options: nil, rubyopt: nil, &test_steps
283288
prepare_test_environment(program, test_steps) do
284289
test_info = TestInfo.new(dup_scenario, 'LOCAL', /\(rdbg\)/)
285290
cmd = "#{RDBG_EXECUTABLE} #{options} -- #{temp_file_path}"
286-
cmd = "RUBYOPT=#{rubyopt} #{cmd}" if rubyopt
291+
ENV["RUBYOPT"] += " #{rubyopt}" if rubyopt
287292
run_test_scenario cmd, test_info
288293
end
289294
end
@@ -301,10 +306,6 @@ def new_thread &block
301306
end
302307
end
303308

304-
def inject_lib_to_load_path
305-
ENV['RUBYOPT'] = "-I #{__dir__}/../../lib"
306-
end
307-
308309
def assert_empty_queue test_info, exception: nil
309310
message = "Expected all commands/assertions to be executed. Still have #{test_info.queue.length} left."
310311
if exception

0 commit comments

Comments
 (0)