Skip to content

Commit 7e19e6f

Browse files
authored
Add test for error handling during task monitoring (#121)
1 parent 9e48ebf commit 7e19e6f

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

test/runtests.jl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,33 @@ end
311311
@test contains(str, "Malt.TerminatedWorkerException")
312312
end
313313

314+
@testset "worker task failure detected by monitor" begin
315+
testsuite = Dict(
316+
"a" => :( @test true ),
317+
)
318+
319+
exception = ErrorException("test_worker exploded")
320+
# A bad test_worker will cause the worker task to error out. With this test
321+
# we want to make sure the task monitoring system catches and handles it.
322+
test_worker(name) = throw(exception)
323+
324+
io = IOBuffer()
325+
try
326+
runtests(ParallelTestRunner, ["--jobs=1"];
327+
test_worker, testsuite, stdout=io, stderr=io)
328+
# The `runtests` above should handle the error, so we shouldn't get here
329+
@test false
330+
catch e
331+
@test typeof(e) === TaskFailedException
332+
@test first(Base.current_exceptions(e.task)).exception == exception
333+
end
334+
str = String(take!(io))
335+
@test contains(str, "Caught an error, stopping...")
336+
@test !contains(str, "SUCCESS")
337+
# Not even FAILURE is printed in this case, we exit very early.
338+
@test !contains(str, "FAILURE")
339+
end
340+
314341
@testset "test output" begin
315342
msg = "This is some output from the test"
316343
testsuite = Dict(

0 commit comments

Comments
 (0)