diff --git a/.github/workflows/heads.yml b/.github/workflows/heads.yml index 0201dda..e5458e2 100644 --- a/.github/workflows/heads.yml +++ b/.github/workflows/heads.yml @@ -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 diff --git a/.rubocop_gradual.lock b/.rubocop_gradual.lock index 24ec251..6591d04 100644 --- a/.rubocop_gradual.lock +++ b/.rubocop_gradual.lock @@ -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], @@ -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": [ diff --git a/README.md b/README.md index 47cc3b8..47ff3fb 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/turbo_tests/cli.rb b/lib/turbo_tests/cli.rb index 89c04bb..33b2b17 100644 --- a/lib/turbo_tests/cli.rb +++ b/lib/turbo_tests/cli.rb @@ -17,6 +17,7 @@ def run verbose = false fail_fast = nil seed = nil + print_failed_group = false create = false OptionParser.new do |opts| @@ -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 @@ -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/ diff --git a/lib/turbo_tests/runner.rb b/lib/turbo_tests/runner.rb index c2b406d..efab4b7 100644 --- a/lib/turbo_tests/runner.rb +++ b/lib/turbo_tests/runner.rb @@ -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 @@ -44,6 +45,7 @@ def self.run(opts = {}) count: count, seed: seed, seed_used: seed_used, + print_failed_group: print_failed_group, ).run end @@ -65,6 +67,7 @@ def initialize(opts) @messages = Thread::Queue.new @threads = [] @error = false + @print_failed_group = opts[:print_failed_group] end def run @@ -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 @@ -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 diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb index f723c32..06d74fd 100644 --- a/spec/cli_spec.rb +++ b/spec/cli_spec.rb @@ -123,11 +123,11 @@ [ /undefined method [`']\[\]' for nil/, - 'it("fails") { expect(nil[:key]).to(eql("value")) }', - /# #{fixture}:2:in [`']block \(2 levels\) in '/, - "1 example, 1 failure", + /it\("fails"\) \{ expect\(nil\[:key\]\).to\(eql\("value"\)\) \}/, + /# #{Regexp.escape(fixture)}:2:in [`']block \(2 levels\) in '/, + /1 example, 1 failure/, ].each do |part| - expect(output).to include(part) + expect(output).to match(part) end end end