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

Exit with special code upon unexpected error #276

Merged
merged 2 commits into from
Jun 10, 2024
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
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 => error
reopen_previous_step
puts red("This worker exited because of an uncaught application error:")
puts red("#{error.class}: #{error.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_application_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
Loading