diff --git a/Project.toml b/Project.toml index 3a20560..7feca0f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ParallelTestRunner" uuid = "d3525ed8-44d0-4b2c-a655-542cee43accc" authors = ["Valentin Churavy "] -version = "2.3.0" +version = "2.4.0" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" diff --git a/src/ParallelTestRunner.jl b/src/ParallelTestRunner.jl index 2e1e633..fc13cc0 100644 --- a/src/ParallelTestRunner.jl +++ b/src/ParallelTestRunner.jl @@ -1115,7 +1115,13 @@ function runtests(mod::Module, args::ParsedArgs; # print the output generated by each testset for (testname, result, output, start, stop) in results if !isempty(output) - println(io_ctx.stdout, "\nOutput generated during execution of '$testname':") + print(io_ctx.stdout, "\nOutput generated during execution of '") + if result isa Exception || anynonpass(result.value) + printstyled(io_ctx.stdout, testname; color=:red) + else + printstyled(io_ctx.stdout, testname; color=:normal) + end + println(io_ctx.stdout, "':") lines = collect(eachline(IOBuffer(output))) for (i,line) in enumerate(lines) @@ -1223,9 +1229,9 @@ function runtests(mod::Module, args::ParsedArgs; print(io_ctx.stdout, c.output) end if !anynonpass(o_ts) - println(io_ctx.stdout, " \033[32;1mSUCCESS\033[0m") + printstyled(io_ctx.stdout, " SUCCESS\n"; bold=true, color=:green) else - println(io_ctx.stderr, " \033[31;1mFAILURE\033[0m\n") + printstyled(io_ctx.stderr, " FAILURE\n\n"; bold=true, color=:red) if VERSION >= v"1.13.0-DEV.1033" Test.print_test_errors(io_ctx.stdout, o_ts) else diff --git a/test/runtests.jl b/test/runtests.jl index 4f09e17..040db00 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -183,20 +183,23 @@ end @testset "failing test" begin testsuite = Dict( "failing test" => quote + println("This test will fail") @test 1 == 2 end ) error_line = @__LINE__() - 3 io = IOBuffer() + ioc = IOContext(io, :color => true) @test_throws Test.FallbackTestSetException("Test run finished with errors") begin - runtests(ParallelTestRunner, ["--verbose"]; testsuite, stdout=io, stderr=io) + runtests(ParallelTestRunner, ["--verbose"]; testsuite, stdout=ioc, stderr=ioc) end str = String(take!(io)) - @test contains(str, r"failing test .+ failed at") + @test contains(str, r"failing test.+ failed at") @test contains(str, "$(basename(@__FILE__)):$error_line") @test contains(str, "FAILURE") + @test contains(str, "Output generated during execution of '\e[31mfailing test\e[39m':") @test contains(str, "Test Failed") @test contains(str, "1 == 2") end @@ -263,11 +266,13 @@ end ) io = IOBuffer() + ioc = IOContext(io, :color => true) @test_throws Test.FallbackTestSetException("Test run finished with errors") begin - runtests(ParallelTestRunner, ["--verbose"]; testsuite, stdout=io, stderr=io) + runtests(ParallelTestRunner, ["--verbose"]; testsuite, stdout=ioc, stderr=ioc) end str = String(take!(io)) + @test contains(str, "Output generated during execution of '\e[31mabort\e[39m':") # Make sure we can capture the output generated by the crashed process, see # issue . @test contains(str, msg) @@ -276,7 +281,7 @@ end @test contains(str, "in expression starting at") # Following are messages printed by ParallelTestRunner. @test contains(str, r"abort .+ started at") - @test contains(str, r"abort .+ crashed at") + @test contains(str, r"abort.+ crashed at") @test contains(str, "FAILURE") @test contains(str, "Error During Test") @test contains(str, "Malt.TerminatedWorkerException")