Skip to content

Commit d0fb4f7

Browse files
committed
Add test for colorful output
1 parent e290463 commit d0fb4f7

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/runtests.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,32 @@ end
230230
@test contains(str, "SUCCESS")
231231
end
232232

233+
# Issue <https://github.com/JuliaTesting/ParallelTestRunner.jl/issues/69>.
234+
@testset "Colorful output" begin
235+
testsuite = Dict(
236+
"color" => quote
237+
printstyled("Roses Are Red"; color=:red)
238+
end
239+
)
240+
io = IOBuffer()
241+
ioc = IOContext(io, :color => true)
242+
runtests(ParallelTestRunner, String[]; testsuite, stdout=ioc, stderr=ioc)
243+
str = String(take!(io))
244+
@test contains(str, "\e[31mRoses Are Red\e[39m\n")
245+
@test contains(str, "SUCCESS")
246+
247+
testsuite = Dict(
248+
"no color" => quote
249+
print("Violets are ")
250+
printstyled("blue"; color=:blue)
251+
end
252+
)
253+
io = IOBuffer()
254+
ioc = IOContext(io, :color => false)
255+
runtests(ParallelTestRunner, String[]; testsuite, stdout=ioc, stderr=ioc)
256+
str = String(take!(io))
257+
@test contains(str, "Violets are blue\n")
258+
@test contains(str, "SUCCESS")
259+
end
260+
233261
end

0 commit comments

Comments
 (0)