diff options
| author | Takashi Kokubun <takashi.kokubun@shopify.com> | 2025-10-08 21:07:11 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-08 21:07:11 -0700 |
| commit | 6922e969f1441ded72d1595397ae50687944827d (patch) | |
| tree | 85076b1b1df763e6a23e5f13daf4766cb47d606a | |
| parent | 5de042f4afb040d9760abcd8f0cf45521409b537 (diff) | |
Allow test-tool to use bundled gems in child processes (#14794)
| -rw-r--r-- | tool/test/init.rb | 12 | ||||
| -rw-r--r-- | tool/test/test_commit_email.rb | 12 |
2 files changed, 14 insertions, 10 deletions
diff --git a/tool/test/init.rb b/tool/test/init.rb index 3a1143d01d..3fd1419a9c 100644 --- a/tool/test/init.rb +++ b/tool/test/init.rb @@ -1,7 +1,15 @@ -# This file includes the settings for "make test-all". +# This file includes the settings for "make test-all" and "make test-tool". # Note that this file is loaded not only by test/runner.rb but also by tool/lib/test/unit/parallel.rb. -ENV["GEM_SKIP"] = ENV["GEM_HOME"] = ENV["GEM_PATH"] = "".freeze +# Prevent test-all from using bundled gems +["GEM_HOME", "GEM_PATH"].each do |gem_env| + # Preserve the gem environment prepared by tool/runruby.rb for test-tool, which uses bundled gems. + ENV["BUNDLED_#{gem_env}"] = ENV[gem_env] + + ENV[gem_env] = "".freeze +end +ENV["GEM_SKIP"] = "".freeze + ENV.delete("RUBY_CODESIGN") Warning[:experimental] = false diff --git a/tool/test/test_commit_email.rb b/tool/test/test_commit_email.rb index 539b0b071c..7b258734d0 100644 --- a/tool/test/test_commit_email.rb +++ b/tool/test/test_commit_email.rb @@ -8,7 +8,7 @@ class TestCommitEmail < Test::Unit::TestCase def setup @ruby = Dir.mktmpdir Dir.chdir(@ruby) do - git('init') + git('init', '--initial-branch=master') git('config', 'user.name', 'Jóhän Grübél') git('config', 'user.email', 'johan@example.com') git('commit', '--allow-empty', '-m', 'New repository initialized by cvs2svn.') @@ -30,11 +30,6 @@ class TestCommitEmail < Test::Unit::TestCase # Just testing an exit status :p # TODO: prepare something in test/fixtures/xxx and test output def test_successful_run - _, err, status = EnvUtil.invoke_ruby([gem_env, '-e', 'require "nkf"'], '', false, true) - unless status.success? - omit "bundled gems are not available: #{err}" - end - Dir.chdir(@ruby) do out, _, status = EnvUtil.invoke_ruby([ { 'SENDMAIL' => @sendmail }.merge!(gem_env), @@ -49,9 +44,10 @@ class TestCommitEmail < Test::Unit::TestCase private - # Cancel the gem environments set by tool/test/init.rb + # Resurrect the gem environment preserved by tool/test/init.rb. + # This should work as long as you have run `make up` or `make install`. def gem_env - { 'GEM_PATH' => nil, 'GEM_HOME' => nil } + { 'GEM_PATH' => ENV['BUNDLED_GEM_PATH'], 'GEM_HOME' => ENV['BUNDLED_GEM_HOME'] } end def git(*cmd) |
