Skip to content

Commit

Permalink
Exit with special code upon unexpected error
Browse files Browse the repository at this point in the history
  • Loading branch information
zarifmahfuz committed May 9, 2024
1 parent 7bb8625 commit 5fa2d3b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ruby/lib/minitest/queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ def run_from_queue(reporter, *)
reopen_previous_step
puts red("The heartbeat process died. This worker is exiting early.")
exit!(41)
rescue StandardError => e
reopen_previous_step
puts red("This worker died because of a queue or framework error:")
puts red("#{e.class}: #{e.message}")
exit!(42)
end
end
end
Expand Down
14 changes: 14 additions & 0 deletions ruby/test/fixtures/test/bad_framework_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true
require "test_helper"

class Minitest::Queue::SingleExample
def run
raise StandardError, "Some error in the test framework"
end
end

class BadFrameworkTest < Minitest::Test
def test_foo
assert false
end
end
21 changes: 21 additions & 0 deletions ruby/test/integration/minitest_redis_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,27 @@ def test_utf8_tests_and_marshal
END
end

def test_framework_error
capture_subprocess_io do
system(
{ 'BUILDKITE' => '1' },
@exe, 'run',
'--queue', @redis_url,
'--seed', 'foobar',
'--build', '1',
'--worker', '1',
'--timeout', '1',
'--max-requeues', '1',
'--requeue-tolerance', '1',
'-Itest',
'test/bad_framework_test.rb',
chdir: 'test/fixtures/',
)
end

assert_equal 42, $?.exitstatus
end

private

def normalize_xml(output)
Expand Down

0 comments on commit 5fa2d3b

Please sign in to comment.