diff --git a/src/ParallelTestRunner.jl b/src/ParallelTestRunner.jl index 5ed2b72..b409c42 100644 --- a/src/ParallelTestRunner.jl +++ b/src/ParallelTestRunner.jl @@ -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) @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index 8159ed9..c201a05 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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") @@ -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