diff --git a/Project.toml b/Project.toml index ab983b7..8bdfe5e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ParallelTestRunner" uuid = "d3525ed8-44d0-4b2c-a655-542cee43accc" authors = ["Valentin Churavy "] -version = "2.0.1" +version = "2.0.2" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" diff --git a/src/ParallelTestRunner.jl b/src/ParallelTestRunner.jl index 1463eee..37b65cd 100644 --- a/src/ParallelTestRunner.jl +++ b/src/ParallelTestRunner.jl @@ -258,7 +258,8 @@ function runtest(f, name, init_code, color) take!(pipe_initialized) read(pipe, String) end - stats = redirect_stdio(stdout=pipe, stderr=pipe) do + io = IOContext(pipe, :color=>$(color)) + stats = redirect_stdio(; stdout=io, stderr=io) do put!(pipe_initialized, nothing) # @testset CustomTestRecord switches the all lower-level testset to our custom testset, diff --git a/test/runtests.jl b/test/runtests.jl index 4bf7e53..1188e00 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -230,4 +230,32 @@ end @test contains(str, "SUCCESS") end +# Issue . +@testset "colorful output" begin + testsuite = Dict( + "color" => quote + printstyled("Roses Are Red"; color=:red) + end + ) + io = IOBuffer() + ioc = IOContext(io, :color => true) + runtests(ParallelTestRunner, String[]; testsuite, stdout=ioc, stderr=ioc) + str = String(take!(io)) + @test contains(str, "\e[31mRoses Are Red\e[39m\n") + @test contains(str, "SUCCESS") + + testsuite = Dict( + "no color" => quote + print("Violets are ") + printstyled("blue"; color=:blue) + end + ) + io = IOBuffer() + ioc = IOContext(io, :color => false) + runtests(ParallelTestRunner, String[]; testsuite, stdout=ioc, stderr=ioc) + str = String(take!(io)) + @test contains(str, "Violets are blue\n") + @test contains(str, "SUCCESS") +end + end