Skip to content

Commit d8e8aa5

Browse files
authored
Merge pull request #70 from bhuga/resilient-against-nil-exit-status
Use an error status instead of nil if we're missing a worker status code
2 parents b2ab6f6 + c58d34f commit d8e8aa5

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

lib/test_queue/runner.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def summarize_internal
146146
unassigned_suites = []
147147
@failures = ''
148148
@completed.each do |worker|
149-
estatus += worker.status.exitstatus
149+
estatus += (worker.status.exitstatus || 1)
150150
@stats.record_suites(worker.suites)
151151
worker.suites.each do |suite|
152152
assignment = @assignments.delete([suite.name, suite.path])
@@ -163,13 +163,12 @@ def summarize_internal
163163

164164
@failures << worker.failure_output if worker.failure_output
165165

166-
puts " [%2d] %60s %4d suites in %.4fs (pid %d exit %d%s)" % [
166+
puts " [%2d] %60s %4d suites in %.4fs (%s %s)" % [
167167
worker.num,
168168
worker.summary,
169169
worker.suites.size,
170170
worker.end_time - worker.start_time,
171-
worker.pid,
172-
worker.status.exitstatus,
171+
worker.status.to_s,
173172
worker.host && " on #{worker.host.split('.').first}"
174173
]
175174
end
@@ -218,6 +217,7 @@ def summarize_internal
218217

219218
summarize
220219

220+
estatus = @completed.inject(0){ |s, worker| s + (worker.status.exitstatus || 1)}
221221
[estatus, 255].min
222222
end
223223

test/minitest5.bats

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ assert_test_queue_force_ordering() {
128128
assert_output_contains "MiniTestFailure#test_fail"
129129
}
130130

131+
@test "recovers from child processes dying in an unorderly way" {
132+
export KILL=1
133+
run bundle exec minitest-queue ./test/samples/sample_minitest5.rb
134+
assert_status 1
135+
assert_output_contains "SIGKILL (signal 9)"
136+
}
137+
131138
@test "minitest-queue fails when TEST_QUEUE_WORKERS is <= 0" {
132139
export TEST_QUEUE_WORKERS=0
133140
run bundle exec minitest-queue ./test/samples/sample_minitest5.rb

test/samples/sample_minitest5.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,11 @@ def test_fail
2323
end
2424
end
2525
end
26+
27+
if ENV["KILL"]
28+
class MiniTestKilledFailure < MiniTest::Test
29+
def test_kill
30+
Process.kill(9, $$)
31+
end
32+
end
33+
end

0 commit comments

Comments
 (0)