Skip to content

Commit 65887ec

Browse files
authored
Merge pull request #3099 from hsbt/claude/ruby-ci-job-failure-a4dfa1
Run `bundle` with the Ruby running the tests
2 parents 4065df1 + fb1709e commit 65887ec

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

‎test/rbs/cli_test.rb‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ def refute_cli_success(exit_status = nil, &)
2727
assert_predicate exit_status, :nonzero?, "Expected CLI to succeed, but it failed with status: #{exit_status.inspect}"
2828
end
2929

30+
# Command to run `bundle` with the Ruby running the tests
31+
#
32+
# The `bundle` executable found in `PATH` may belong to another Ruby installation, which aborts
33+
# with a version mismatch error when `RUBYLIB` points at the standard library of the running Ruby.
34+
# That is what happens in ruby/ruby CI, where the tests run with a freshly built `ruby`.
35+
#
36+
BUNDLE_COMMAND = [RbConfig.ruby, "-S", "bundle"]
37+
3038
# Run `rbs collection` with fresh bundler environment
3139
#
3240
# You need this method to test `rbs collection` features.
@@ -35,20 +43,18 @@ def refute_cli_success(exit_status = nil, &)
3543
# - If `bundler: true` is given, it runs `rbs collection` command with `bundle exec`
3644
# - If `bundler: false` is given, it runs `rbs collection` command without `bundle exec`
3745
#
38-
# We cannot run tests that uses this method in ruby CI.
39-
#
4046
def run_rbs_collection(*commands, bundler:)
4147
stdout, stderr, status =
4248
Bundler.with_unbundled_env do
4349
bundle_exec = []
44-
bundle_exec = ["bundle", "exec"] if bundler
50+
bundle_exec = [*BUNDLE_COMMAND, "exec"] if bundler
4551

4652
rbs_path = Pathname("#{__dir__}/../../lib").cleanpath.to_s
4753
if rblib = ENV["RUBYLIB"]
4854
rbs_path << (":" + rblib)
4955
end
5056

51-
Open3.capture3({ "RUBYLIB" => rbs_path }, *bundle_exec, "#{__dir__}/../../exe/rbs", "--log-level=debug", "collection", *commands, chdir: Dir.pwd)
57+
Open3.capture3({ "RUBYLIB" => rbs_path }, *bundle_exec, RbConfig.ruby, "#{__dir__}/../../exe/rbs", "--log-level=debug", "collection", *commands, chdir: Dir.pwd)
5258
end
5359

5460
if block_given?
@@ -83,7 +89,7 @@ def bundle_install(*gems)
8389
#{gems.join("\n")}
8490
RUBY
8591

86-
Open3.capture3("bundle", "install", chdir: Dir.pwd)
92+
Open3.capture3(*BUNDLE_COMMAND, "install", chdir: Dir.pwd)
8793
end
8894

8995
assert_predicate status, :success?, stderr

0 commit comments

Comments
 (0)