Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ParallelTestRunner"
uuid = "d3525ed8-44d0-4b2c-a655-542cee43accc"
authors = ["Valentin Churavy <[email protected]>"]
version = "2.0.1"
version = "2.0.2"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
2 changes: 1 addition & 1 deletion src/ParallelTestRunner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ function runtest(f, name, init_code, color)
take!(pipe_initialized)
read(pipe, String)
end
stats = redirect_stdio(stdout=pipe, stderr=pipe) do
stats = redirect_stdio(; stdout=IOContext(pipe, :color=>$(color)), stderr=IOContext(pipe, :color=>$(color))) do
put!(pipe_initialized, nothing)

# @testset CustomTestRecord switches the all lower-level testset to our custom testset,
Expand Down
28 changes: 28 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,32 @@ end
@test contains(str, "SUCCESS")
end

# Issue <https://github.com/JuliaTesting/ParallelTestRunner.jl/issues/69>.
@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