brew/Library/Homebrew/.rspec_parallel
Jason Rudolph e163eb8650
Enhance test suite to emit JUnit XML test reports
In preparation for detecting flaky tests with BuildPulse, this commit
sets up the rspec_junit_formatter gem to output JUnit XML reports of the
test suite, which is the format used by BuildPulse and various other
tooling that interprets test results.

Because the test suite uses the parallel_tests gem, this commit
incorporates some related changes to make all the parallel_tests gem and
the rspec_junit_formatter gem to cooperate with each other.

rspec_junit_formatter writes everything to a single XML file. That works
fine when there's only one process writing to the file. By default,
whatever process finishes last will write to the file and clobber the
output of all the other processes that wrote to the file. 🙈

To prevent this issue, the parallel_tests wiki recommends adding a
`.rspec_parallel` file to specify its RSpec options
(https://github.com/grosser/parallel_tests/wiki#with-rspec_junit_formatter----by-jgarber),
then the project can specify different files for each process to write
to like so:

  --format RspecJunitFormatter
  --out tmp/rspec<%= ENV['TEST_ENV_NUMBER'] %>.xml

However, prior to this commit, the Homebrew/brew test suite specified
its RSpec options via the command line. Unfortunately though, there's no
way (AFAICT) to set the equivalent of these options via the command
line:

  --format RspecJunitFormatter
  --out tmp/rspec<%= ENV['TEST_ENV_NUMBER'] %>.xml

So, we need to use a `.rspec_parallel` file to specify these options ☝️.

However, it appears that RSpec allows you to specify formatters _either_
in an options file (like `.rspec_parallel`) _or_ via command-line args.
But if you specify any formatters via command-line args, then all
formatters in the options file are ignored.  (I suspect that's somehow
related to this bit of code in rspec-core:
https://github.com/rspec/rspec-core/blob/v3.10.0/lib/rspec/core/configuration_options.rb#L64.)

With that in mind, in order to have the RspecJunitFormatter configured
 in `.rspec_parallel`, we need to move the other formatters into
 `.rpsec_parallel` as well, instead of passing them as command-line
 args. Therefore, this commit moves all the formatters into a
 `.rspec_parallel` file.
2021-06-21 13:14:18 -04:00

7 lines
275 B
Plaintext

--format NoSeedProgressFormatter
--format ParallelTests::RSpec::RuntimeLogger
--out <%= ENV["PARALLEL_RSPEC_LOG_PATH"] %>
--format RspecJunitFormatter
--out test/junit/rspec<%= ENV["TEST_ENV_NUMBER"] %>.xml
<%= "--format RSpec::Github::Formatter" if ENV["GITHUB_ACTIONS"] %>