aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike McQuaid2017-12-15 09:14:44 +0000
committerMike McQuaid2017-12-15 09:14:44 +0000
commit8ed1425ed7d53b93b5c90f1f340ca3e273d51a86 (patch)
treeccd25a863ef5509452510ce6d3bb527c836254b3
parent71ebfa76c53408a2fb40cbc95bb6f39be27da6b7 (diff)
downloadbrew-8ed1425ed7d53b93b5c90f1f340ca3e273d51a86.tar.bz2
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.
-rw-r--r--Library/Homebrew/dev-cmd/tests.rb11
-rw-r--r--Library/Homebrew/test/spec_helper.rb1
-rw-r--r--Library/Homebrew/test/support/no_seed_progress_formatter.rb7
3 files changed, 16 insertions, 3 deletions
diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb
index af9dcc575..db2a6d33e 100644
--- a/Library/Homebrew/dev-cmd/tests.rb
+++ b/Library/Homebrew/dev-cmd/tests.rb
@@ -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
diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb
index 08766ea37..be184b6e0 100644
--- a/Library/Homebrew/test/spec_helper.rb
+++ b/Library/Homebrew/test/spec_helper.rb
@@ -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"
diff --git a/Library/Homebrew/test/support/no_seed_progress_formatter.rb b/Library/Homebrew/test/support/no_seed_progress_formatter.rb
new file mode 100644
index 000000000..e87a58143
--- /dev/null
+++ b/Library/Homebrew/test/support/no_seed_progress_formatter.rb
@@ -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