-
Notifications
You must be signed in to change notification settings - Fork 30
Remove default seed
value
#48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
3fe0ce0
b4a886b
c5bf35c
99a0e04
84f2487
6455e65
4115412
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
turbo_tests (2.2.3) | ||
turbo_tests (2.2.4) | ||
parallel_tests (>= 3.3.0, < 5) | ||
rspec (>= 3.10) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
RSpec.describe "NoMethodError spec" do | ||
it("fails") { expect(nil[:key]).to eql("value") } | ||
end |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -14,20 +14,19 @@ def self.run(opts = {}) | |||||||||||||
formatters = opts[:formatters] | ||||||||||||||
tags = opts[:tags] | ||||||||||||||
|
||||||||||||||
# SEE: https://bit.ly/2NP87Cz | ||||||||||||||
start_time = opts.fetch(:start_time) { Process.clock_gettime(Process::CLOCK_MONOTONIC) } | ||||||||||||||
start_time = opts.fetch(:start_time) { RSpec::Core::Time.now } | ||||||||||||||
runtime_log = opts.fetch(:runtime_log, nil) | ||||||||||||||
verbose = opts.fetch(:verbose, false) | ||||||||||||||
fail_fast = opts.fetch(:fail_fast, nil) | ||||||||||||||
count = opts.fetch(:count, nil) | ||||||||||||||
seed = opts.fetch(:seed) || rand(0xFFFF).to_s | ||||||||||||||
seed_used = !opts[:seed].nil? | ||||||||||||||
seed = opts.fetch(:seed) | ||||||||||||||
seed_used = !seed.nil? | ||||||||||||||
|
||||||||||||||
if verbose | ||||||||||||||
warn "VERBOSE" | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
reporter = Reporter.from_config(formatters, start_time) | ||||||||||||||
reporter = Reporter.from_config(formatters, start_time, seed, seed_used) | ||||||||||||||
|
||||||||||||||
new( | ||||||||||||||
reporter: reporter, | ||||||||||||||
|
@@ -38,7 +37,7 @@ def self.run(opts = {}) | |||||||||||||
fail_fast: fail_fast, | ||||||||||||||
count: count, | ||||||||||||||
seed: seed, | ||||||||||||||
seed_used: seed_used | ||||||||||||||
seed_used: seed_used, | ||||||||||||||
).run | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
|
@@ -50,11 +49,12 @@ def initialize(opts) | |||||||||||||
@verbose = opts[:verbose] | ||||||||||||||
@fail_fast = opts[:fail_fast] | ||||||||||||||
@count = opts[:count] | ||||||||||||||
@seed = opts[:seed] | ||||||||||||||
@seed_used = opts[:seed_used] | ||||||||||||||
|
||||||||||||||
@load_time = 0 | ||||||||||||||
@load_count = 0 | ||||||||||||||
@failure_count = 0 | ||||||||||||||
@seed = opts[:seed] | ||||||||||||||
@seed_used = opts[:seed_used] | ||||||||||||||
|
||||||||||||||
@messages = Thread::Queue.new | ||||||||||||||
@threads = [] | ||||||||||||||
|
@@ -87,26 +87,25 @@ def run | |||||||||||||
setup_tmp_dir | ||||||||||||||
|
||||||||||||||
subprocess_opts = { | ||||||||||||||
record_runtime: use_runtime_info | ||||||||||||||
record_runtime: use_runtime_info, | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
report_number_of_tests(tests_in_groups) | ||||||||||||||
|
||||||||||||||
@reporter.seed_notification(@seed, @seed_used) | ||||||||||||||
|
||||||||||||||
wait_threads = tests_in_groups.map.with_index do |tests, process_id| | ||||||||||||||
start_regular_subprocess(tests, process_id + 1, **subprocess_opts) | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
handle_messages | ||||||||||||||
|
||||||||||||||
@reporter.finish | ||||||||||||||
@reporter.report(tests_in_groups) do |reporter| | ||||||||||||||
wait_threads = tests_in_groups.map.with_index do |tests, process_id| | ||||||||||||||
start_regular_subprocess(tests, process_id + 1, **subprocess_opts) | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
@reporter.seed_notification(@seed, @seed_used) | ||||||||||||||
handle_messages | ||||||||||||||
|
||||||||||||||
@threads.each(&:join) | ||||||||||||||
@threads.each(&:join) | ||||||||||||||
|
||||||||||||||
@reporter.failed_examples.empty? && wait_threads.map(&:value).all?(&:success?) | ||||||||||||||
if @reporter.failed_examples.empty? && wait_threads.map(&:value).all?(&:success?) | ||||||||||||||
0 | ||||||||||||||
else | ||||||||||||||
# From https://github.com/serpapi/turbo_tests/pull/20/ | ||||||||||||||
wait_threads.map { |thread| thread.value.exitstatus }.max | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
private | ||||||||||||||
|
@@ -157,12 +156,18 @@ def start_subprocess(env, extra_args, tests, process_id, record_runtime:) | |||||||||||||
[] | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
seed_option = if @seed_used | ||||||||||||||
[ | ||||||||||||||
"--seed", @seed, | ||||||||||||||
] | ||||||||||||||
else | ||||||||||||||
[] | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
command = [ | ||||||||||||||
*command_name, | ||||||||||||||
*extra_args, | ||||||||||||||
"--seed", rand(0xFFFF).to_s, | ||||||||||||||
"--format", "ParallelTests::RSpec::RuntimeLogger", | ||||||||||||||
"--out", @runtime_log, | ||||||||||||||
*seed_option, | ||||||||||||||
"--format", "TurboTests::JsonRowsFormatter", | ||||||||||||||
*record_runtime_options, | ||||||||||||||
*tests, | ||||||||||||||
|
@@ -254,12 +259,17 @@ def handle_messages | |||||||||||||
break | ||||||||||||||
end | ||||||||||||||
when "message" | ||||||||||||||
@reporter.message(message[:message]) | ||||||||||||||
if message[:message].include?("An error occurred") || message[:message].include?("occurred outside of examples") | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have to check message contents because RSpec outputs errors outside of examples as regular messages which we format in Ref Ref turbo_tests/lib/turbo_tests/json_rows_formatter.rb Lines 97 to 102 in bb814e1
Errors outside of examples begin with
And end with |
||||||||||||||
@reporter.error_outside_of_examples(message[:message]) | ||||||||||||||
@error = true | ||||||||||||||
else | ||||||||||||||
@reporter.message(message[:message]) | ||||||||||||||
end | ||||||||||||||
when "seed" | ||||||||||||||
when "close" | ||||||||||||||
when "error" | ||||||||||||||
@reporter.error_outside_of_examples | ||||||||||||||
@error = true | ||||||||||||||
# Do nothing | ||||||||||||||
nil | ||||||||||||||
when "exit" | ||||||||||||||
exited += 1 | ||||||||||||||
if exited == @num_processes | ||||||||||||||
|
@@ -277,15 +287,5 @@ def handle_messages | |||||||||||||
def fail_fast_met | ||||||||||||||
!@fail_fast.nil? && @failure_count >= @fail_fast | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
def report_number_of_tests(groups) | ||||||||||||||
name = ParallelTests::RSpec::Runner.test_file_name | ||||||||||||||
|
||||||||||||||
num_processes = groups.size | ||||||||||||||
num_tests = groups.map(&:size).sum | ||||||||||||||
tests_per_process = (num_processes == 0 ? 0 : num_tests.to_f / num_processes).round | ||||||||||||||
|
||||||||||||||
puts "#{num_processes} processes for #{num_tests} #{name}s, ~ #{tests_per_process} #{name}s per process" | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module TurboTests | ||
VERSION = "2.2.3" | ||
VERSION = "2.2.4" | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like that
TurboTests::Reporter
almost entirely duplicatesRSpec::Core::Reporter
. I'll try to inheritRSpec::Core::Reporter
or do something similar to avoid duplication.