From d09e4f5075f29e99214da81f083fad96b06f11c4 Mon Sep 17 00:00:00 2001 From: Christian Bruckmayer Date: Wed, 15 Mar 2023 08:44:24 +0000 Subject: [PATCH] Abort when too many test failed We should not assume the reporter will report a non 0 exit code as all tests could be retried. --- ruby/lib/minitest/queue/runner.rb | 2 +- ruby/test/integration/minitest_redis_test.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ruby/lib/minitest/queue/runner.rb b/ruby/lib/minitest/queue/runner.rb index 6c3b88f1..153e2646 100644 --- a/ruby/lib/minitest/queue/runner.rb +++ b/ruby/lib/minitest/queue/runner.rb @@ -199,7 +199,7 @@ def report_command msg = "#{supervisor.size} tests weren't run." if supervisor.max_test_failed? puts('Encountered too many failed tests. Test run was ended early.') - puts(msg) + abort!(msg) else abort!(msg) end diff --git a/ruby/test/integration/minitest_redis_test.rb b/ruby/test/integration/minitest_redis_test.rb index c5bbc737..d0ca2d7b 100644 --- a/ruby/test/integration/minitest_redis_test.rb +++ b/ruby/test/integration/minitest_redis_test.rb @@ -91,6 +91,7 @@ def test_max_test_failed assert_equal 'Ran 47 tests, 47 assertions, 3 failures, 0 errors, 0 skips, 44 requeues in X.XXs', output # Run the reporter + exit_code = nil out, err = capture_subprocess_io do system( @exe, 'report', @@ -102,12 +103,13 @@ def test_max_test_failed chdir: 'test/fixtures/', ) end + + refute_predicate $?, :success? assert_empty err expected = <<~EXPECTED Waiting for workers to complete Encountered too many failed tests. Test run was ended early. 97 tests weren't run. - Ran 3 tests, 47 assertions, 3 failures, 0 errors, 0 skips, 44 requeues in X.XXs (aggregated) EXPECTED assert_equal expected.strip, normalize(out.lines[0..4].join.strip) end