Skip to content

Fix incompatibility with rake 13.4+ verbose mode#13

Open
ogajduse wants to merge 1 commit intoci-reporter:masterfrom
ogajduse:fix-rake-13.4-testopts-conflict
Open

Fix incompatibility with rake 13.4+ verbose mode#13
ogajduse wants to merge 1 commit intoci-reporter:masterfrom
ogajduse:fix-rake-13.4-testopts-conflict

Conversation

@ogajduse
Copy link
Copy Markdown

Problem

Rake 13.4.0 introduced verbose console support by setting ENV["TESTOPTS"] = "-v" (ruby/rake#394). Rake 13.4.2 improved this to preserve existing TESTOPTS values and append -v only when not present (ruby/rake#723).

However, ci_reporter_test_unit was adding the test_unit_loader.rb file path to TESTOPTS, which caused conflicts:

Before rake 13.4.2:

  • TESTOPTS was overwritten, breaking ci_reporter entirely

After rake 13.4.2:

  • TESTOPTS preserved, but appending -v caused rake_test_loader to interpret the loader file as a test file
  • Results in rake_test_loader: version unknown or <filename>: version unknown errors
  • Affects projects using t.verbose = true in Rake::TestTask

Solution

Use RUBYOPT with Ruby's -r flag instead of TESTOPTS. This properly requires the loader before tests run, avoiding conflicts with rake's verbose handling.

Testing

Manually tested with:

  • rake 13.4.2
  • Rake::TestTask with t.verbose = true
  • Verified XML reports are generated correctly
  • Verified verbose output works when enabled

References

Compatibility

This change is backwards compatible - RUBYOPT with -r works with all Ruby and rake versions.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant