Skip to content
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

Pull 34 #3

Merged
merged 3 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .github/workflows/heads.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ jobs:
bundler: latest

# jruby-head
- ruby: "jruby-head"
appraisal: "jruby-head"
exec_cmd: "turbo_tests -n4"
gemfile: "Appraisal.root"
rubygems: latest
bundler: latest
# Error output has a significantly different format in JRuby :(
# - ruby: "jruby-head"
# appraisal: "jruby-head"
# exec_cmd: "turbo_tests -n4"
# gemfile: "Appraisal.root"
# rubygems: latest
# bundler: latest

steps:
- name: Checkout
Expand Down
18 changes: 9 additions & 9 deletions .rubocop_gradual.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@
"lib/turbo_tests/reporter.rb:1386902608": [
[7, 5, 400, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 2092085575]
],
"lib/turbo_tests/runner.rb:3148178217": [
"lib/turbo_tests/runner.rb:2204434148": [
[13, 5, 271, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 21989008],
[20, 5, 798, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 2396047272],
[198, 11, 10, "ThreadSafety/NewThread: Avoid starting new threads.", 3411682361],
[216, 47, 6, "Style/GlobalStdStream: Use `$stderr` instead of `STDERR`.", 3356712163],
[218, 21, 10, "ThreadSafety/NewThread: Avoid starting new threads.", 3411682361],
[227, 7, 10, "ThreadSafety/NewThread: Avoid starting new threads.", 3411682361],
[287, 9, 6, "Style/GlobalStdStream: Use `$stdout` instead of `STDOUT`.", 3356722952]
[20, 5, 917, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 1582439743],
[203, 11, 10, "ThreadSafety/NewThread: Avoid starting new threads.", 3411682361],
[221, 47, 6, "Style/GlobalStdStream: Use `$stderr` instead of `STDERR`.", 3356712163],
[223, 21, 10, "ThreadSafety/NewThread: Avoid starting new threads.", 3411682361],
[232, 7, 10, "ThreadSafety/NewThread: Avoid starting new threads.", 3411682361],
[292, 9, 6, "Style/GlobalStdStream: Use `$stdout` instead of `STDOUT`.", 3356722952]
],
"spec/cli_spec.rb:43879232": [
"spec/cli_spec.rb:3990998076": [
[1, 1, 30, "RSpec/SpecFilePathFormat: Spec path should end with `turbo_tests/cli*_spec.rb`.", 965721356],
[11, 13, 28, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 2146945865],
[30, 7, 12, "RSpec/MultipleExpectations: Example has too many expectations [3/1].", 2388739333],
Expand All @@ -51,7 +51,7 @@
[111, 5, 32, "RSpec/MultipleExpectations: Example has too many expectations [2/1].", 281328851],
[112, 32, 3, "RSpec/BeEql: Prefer `be` over `eql`.", 193405885],
[121, 5, 38, "RSpec/MultipleExpectations: Example has too many expectations [2/1].", 3463001811],
[121, 5, 384, "RSpec/ExampleLength: Example has too many lines. [9/5]", 4122755410],
[121, 5, 409, "RSpec/ExampleLength: Example has too many lines. [9/5]", 4122755410],
[122, 32, 3, "RSpec/BeEql: Prefer `be` over `eql`.", 193405885]
],
"spec/doc_formatter_spec.rb:233381593": [
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ Options:
--fail-fast=[N]
--seed SEED Seed for rspec
--create Create test databases
--print_failed_group Prints group that had failures in it
```

## Development
Expand Down
6 changes: 6 additions & 0 deletions lib/turbo_tests/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def run
verbose = false
fail_fast = nil
seed = nil
print_failed_group = false
create = false

OptionParser.new do |opts|
Expand Down Expand Up @@ -90,6 +91,10 @@ def run
opts.on("--create", "Create databases") do
create = true
end

opts.on("--print_failed_group", "Prints group that had failures in it") do
print_failed_group = true
end
end.parse!(@argv)

if create
Expand Down Expand Up @@ -118,6 +123,7 @@ def run
fail_fast: fail_fast,
count: count,
seed: seed,
print_failed_group: print_failed_group,
)

# From https://github.com/serpapi/turbo_tests/pull/20/
Expand Down
16 changes: 15 additions & 1 deletion lib/turbo_tests/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ def self.run(opts = {})
verbose = opts.fetch(:verbose, false)
fail_fast = opts.fetch(:fail_fast, nil)
count = opts.fetch(:count, nil)
seed = opts.fetch(:seed)
seed = opts.fetch(:seed, nil)
seed_used = !seed.nil?
print_failed_group = opts.fetch(:print_failed_group, false)

warn("VERBOSE") if verbose

Expand All @@ -44,6 +45,7 @@ def self.run(opts = {})
count: count,
seed: seed,
seed_used: seed_used,
print_failed_group: print_failed_group,
).run
end

Expand All @@ -65,6 +67,7 @@ def initialize(opts)
@messages = Thread::Queue.new
@threads = []
@error = false
@print_failed_group = opts[:print_failed_group]
end

def run
Expand Down Expand Up @@ -105,6 +108,8 @@ def run

@threads.each(&:join)

report_failed_group(wait_threads, tests_in_groups) if @print_failed_group

if @reporter.failed_examples.empty? && wait_threads.map(&:value).all?(&:success?)
0
else
Expand Down Expand Up @@ -292,5 +297,14 @@ def handle_messages
def fail_fast_met
!@fail_fast.nil? && @failure_count >= @fail_fast
end

def report_failed_group(wait_threads, tests_in_groups)
wait_threads.map(&:value).each_with_index do |value, index|
next if value.success?

failing_group = tests_in_groups[index].join(" ")
puts "Group that failed: #{failing_group}"
end
end
end
end
8 changes: 4 additions & 4 deletions spec/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@

[
/undefined method [`']\[\]' for nil/,
'it("fails") { expect(nil[:key]).to(eql("value")) }',
/# #{fixture}:2:in [`']block \(2 levels\) in <top \(required\)>'/,
"1 example, 1 failure",
/it\("fails"\) \{ expect\(nil\[:key\]\).to\(eql\("value"\)\) \}/,
/# #{Regexp.escape(fixture)}:2:in [`']block \(2 levels\) in <top \(required\)>'/,
/1 example, 1 failure/,
].each do |part|
expect(output).to include(part)
expect(output).to match(part)
end
end
end
Expand Down
Loading