From 5224f4cf4f7db93658f51543db06dde45a5c970d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Gajdu=C5=A1ek?= Date: Fri, 17 Apr 2026 18:24:35 +0200 Subject: [PATCH] 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: https://github.com/ruby/rake/pull/723 See: https://github.com/ruby/rake/pull/394 --- lib/ci/reporter/rake/test_unit.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ci/reporter/rake/test_unit.rb b/lib/ci/reporter/rake/test_unit.rb index d7ece1e..4a478eb 100644 --- a/lib/ci/reporter/rake/test_unit.rb +++ b/lib/ci/reporter/rake/test_unit.rb @@ -5,7 +5,11 @@ task :testunit do rm_rf ENV["CI_REPORTS"] || "test/reports" test_loader = CI::Reporter.maybe_quote_filename "#{File.dirname(__FILE__)}/test_unit_loader.rb" - ENV["TESTOPTS"] = "#{ENV["TESTOPTS"]} #{test_loader}" + # Use RUBYOPT instead of TESTOPTS to avoid conflicts with rake 13.4+ + # which now preserves TESTOPTS and appends -v when verbose is enabled. + # Adding a file path to TESTOPTS caused rake_test_loader to treat the + # loader file as a test file, resulting in "version unknown" errors. + ENV["RUBYOPT"] = "#{ENV["RUBYOPT"]} -r#{test_loader}" end end end