tests: don't output seed multiple times.

This clutters up the output. Instead, hide it with a RSpec formatter and
generate and output it ourselves.
This commit is contained in:
Mike McQuaid 2017-12-15 09:14:44 +00:00
parent 71ebfa76c5
commit 8ed1425ed7
3 changed files with 16 additions and 3 deletions

View File

@ -82,17 +82,20 @@ module Homebrew
]
end
# Generate seed ourselves and output later to avoid multiple different
# seeds being output when running parallel tests.
seed = ARGV.include?("--seed") ? ARGV.next : rand(0xFFFF).to_i
args = ["-I", HOMEBREW_LIBRARY_PATH/"test"]
args += %W[
--seed #{seed}
--color
--require spec_helper
--format progress
--format NoSeedProgressFormatter
--format ParallelTests::RSpec::RuntimeLogger
--out #{HOMEBREW_CACHE}/tests/parallel_runtime_rspec.log
]
args << "--seed" << ARGV.next if ARGV.include? "--seed"
unless OS.mac?
args << "--tag" << "~needs_macos"
files = files.reject { |p| p =~ %r{^test/(os/mac|cask)(/.*|_spec\.rb)$} }
@ -102,6 +105,8 @@ module Homebrew
files = files.reject { |p| p =~ %r{^test/os/linux(/.*|_spec\.rb)$} }
end
puts "Randomized with seed #{seed}"
if parallel
system "bundle", "exec", "parallel_rspec", *opts, "--", *args, "--", *files
else

View File

@ -5,6 +5,7 @@ require "rspec/wait"
require "rubocop"
require "rubocop/rspec/support"
require "set"
require "support/no_seed_progress_formatter"
if ENV["HOMEBREW_TESTS_COVERAGE"]
require "simplecov"

View File

@ -0,0 +1,7 @@
require "rspec/core/formatters/progress_formatter"
class NoSeedProgressFormatter < RSpec::Core::Formatters::ProgressFormatter
RSpec::Core::Formatters.register self, :seed
def seed(notification); end
end