Skip to content
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
16 changes: 15 additions & 1 deletion ruby/lib/minitest/queue/build_status_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,16 @@ def requeued_tests
build.requeued_tests
end

APPLICATION_ERROR_EXIT_CODE = 42
TIMED_OUT_EXIT_CODE = 43
TOO_MANY_FAILED_TESTS_EXIT_CODE = 44
WORKERS_DIED_EXIT_CODE = 45
SUCCESS_EXIT_CODE = 0
TEST_FAILURE_EXIT_CODE = 1

def report
exit_code = TEST_FAILURE_EXIT_CODE

if requeued_tests.to_a.any?
step("Requeued #{requeued_tests.size} tests")
requeued_tests.to_a.sort.each do |test_id, count|
Expand All @@ -131,10 +140,14 @@ def report
if remaining_tests.size > 10
puts " ..."
end

exit_code = TIMED_OUT_EXIT_CODE
elsif supervisor.time_left_with_no_workers.to_i <= 0
puts red("All workers died.")
exit_code = WORKERS_DIED_EXIT_CODE
elsif supervisor.max_test_failed?
puts red("Encountered too many failed tests. Test run was ended early.")
exit_code = TOO_MANY_FAILED_TESTS_EXIT_CODE
end

puts
Expand All @@ -146,9 +159,10 @@ def report
puts red("Worker #{worker_id } crashed")
puts error
puts ""
exit_code = APPLICATION_ERROR_EXIT_CODE
end

success?
success? ? SUCCESS_EXIT_CODE : exit_code
end

def success?
Expand Down
9 changes: 4 additions & 5 deletions ruby/lib/minitest/queue/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,20 +258,19 @@ def report_command

unless supervisor.exhausted?
reporter = BuildStatusReporter.new(supervisor: supervisor)
reporter.report
exit_code = reporter.report
reporter.write_failure_file(queue_config.failure_file) if queue_config.failure_file
reporter.write_flaky_tests_file(queue_config.export_flaky_tests_file) if queue_config.export_flaky_tests_file

abort!("#{supervisor.size} tests weren't run.")
abort!("#{supervisor.size} tests weren't run.", exit_code)
end
end

reporter = BuildStatusReporter.new(supervisor: supervisor)
reporter.write_failure_file(queue_config.failure_file) if queue_config.failure_file
reporter.write_flaky_tests_file(queue_config.export_flaky_tests_file) if queue_config.export_flaky_tests_file
reporter.report

exit! reporter.success? ? 0 : 1
exit_code = reporter.report
exit! exit_code
end

def report_grind_command
Expand Down
4 changes: 3 additions & 1 deletion ruby/test/integration/minitest_redis_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ def test_max_test_failed
end

refute_predicate $?, :success?
assert_equal 44, $?.exitstatus
assert_empty err
expected = <<~EXPECTED
Waiting for workers to complete
Expand Down Expand Up @@ -264,6 +265,7 @@ def test_all_workers_died
end

refute_predicate $?, :success?
assert_equal 40, $?.exitstatus
assert_empty err
expected = <<~EXPECTED
Waiting for workers to complete
Expand Down Expand Up @@ -1018,7 +1020,7 @@ def test_application_error
assert_includes out, "Worker 1 crashed"
assert_includes out, "Some error in the test framework"

assert_equal 1, $?.exitstatus
assert_equal 42, $?.exitstatus
end

private
Expand Down
Loading