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: 10 additions & 6 deletions src/ParallelTestRunner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function runtest(::Type{TestRecord}, f, name, init_code, color)
function inner()
# generate a temporary module to execute the tests in
mod = @eval(Main, module $(gensym(name)) end)
@eval(mod, import ParallelTestRunner: Test, Random, IOCapture)
@eval(mod, import ParallelTestRunner: Test, Random)
@eval(mod, using .Test, .Random)

Core.eval(mod, init_code)
Expand All @@ -207,13 +207,17 @@ function runtest(::Type{TestRecord}, f, name, init_code, color)
GC.gc(true)
Random.seed!(1)

stats = @timed IOCapture.capture(; color=$color) do
@testset $name begin
$f
mktemp() do path, io
stats = redirect_stdio(stdout=io, stderr=io) do
@timed @testset $name begin
$f
end
end
close(io)
output = read(path, String)
(; testset=stats.value, output, stats.time, stats.bytes, stats.gctime)

end
captured = stats.value
(; testset=captured.value, captured.output, stats.time, stats.bytes, stats.gctime)
end

# process results
Expand Down
17 changes: 17 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,12 @@ end
end
)

println("NOTE: The next test is expected to crash a worker process, which may print some output to the terminal.")
io = IOBuffer()
@test_throws Test.FallbackTestSetException("Test run finished with errors") begin
runtests(ParallelTestRunner, ["--verbose"]; custom_tests, stdout=io, stderr=io)
end
println()

str = String(take!(io))
@test contains(str, r"crash .+ started at")
Expand All @@ -151,4 +153,19 @@ end
@test contains(str, "SUCCESS")
end

@testset "warnings" begin
custom_tests = Dict(
"warning" => quote
@test_warn "3.0" @warn "3.0"
end
)

io = IOBuffer()
runtests(ParallelTestRunner, ["--verbose"]; custom_tests, stdout=io, stderr=io)

str = String(take!(io))
@test contains(str, r"warning .+ started at")
@test contains(str, "SUCCESS")
end

end