Skip to content

Commit 5224f4c

Browse files
committed
Fix incompatibility with rake 13.4+ verbose mode
Rake 13.4.0 (PR ruby/rake#394) introduced verbose console support by setting ENV["TESTOPTS"] = "-v". Rake 13.4.2 (PR ruby/rake#723) fixed this to preserve existing TESTOPTS values and append -v only when not present. However, ci_reporter_test_unit was adding the test_unit_loader.rb file path to TESTOPTS, which caused conflicts: 1. Before rake 13.4.2: TESTOPTS was overwritten, breaking ci_reporter 2. After rake 13.4.2: TESTOPTS preserved, but appending -v caused rake_test_loader to interpret the loader file as a test file, resulting in "version unknown" errors The fix uses RUBYOPT with Ruby's -r flag instead of TESTOPTS. This properly requires the loader before tests run, avoiding the conflict with rake's verbose handling. Fixes compatibility with: - Rake 13.4.0+ with Rake::TestTask verbose mode enabled - Projects using t.verbose = true in Rakefile See: ruby/rake#723 See: ruby/rake#394
1 parent fccc1ac commit 5224f4c

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

lib/ci/reporter/rake/test_unit.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
task :testunit do
66
rm_rf ENV["CI_REPORTS"] || "test/reports"
77
test_loader = CI::Reporter.maybe_quote_filename "#{File.dirname(__FILE__)}/test_unit_loader.rb"
8-
ENV["TESTOPTS"] = "#{ENV["TESTOPTS"]} #{test_loader}"
8+
# Use RUBYOPT instead of TESTOPTS to avoid conflicts with rake 13.4+
9+
# which now preserves TESTOPTS and appends -v when verbose is enabled.
10+
# Adding a file path to TESTOPTS caused rake_test_loader to treat the
11+
# loader file as a test file, resulting in "version unknown" errors.
12+
ENV["RUBYOPT"] = "#{ENV["RUBYOPT"]} -r#{test_loader}"
913
end
1014
end
1115
end

0 commit comments

Comments
 (0)