8686struct TestIOContext
8787 stdout :: IO
8888 stderr :: IO
89+ color:: Bool
8990 lock:: ReentrantLock
9091 name_align:: Int
9192 elapsed_align:: Int
@@ -102,8 +103,10 @@ function test_IOContext(::Type{TestRecord}, stdout::IO, stderr::IO, lock::Reentr
102103 alloc_align = textwidth (" Alloc (MB)" )
103104 rss_align = textwidth (" RSS (MB)" )
104105
106+ color = get (stdout , :color , false )
107+
105108 return TestIOContext (
106- stdout , stderr , lock, name_align, elapsed_align, gc_align, percent_align,
109+ stdout , stderr , color, lock, name_align, elapsed_align, gc_align, percent_align,
107110 alloc_align, rss_align
108111 )
109112end
181184# entry point
182185#
183186
184- function runtest (:: Type{TestRecord} , f, name, init_code)
187+ function runtest (:: Type{TestRecord} , f, name, init_code, color )
185188 function inner ()
186189 # generate a temporary module to execute the tests in
187190 mod_name = Symbol (" Test" , rand (1 : 100 ), " Main_" , replace (name, ' /' => ' _' ))
@@ -195,7 +198,7 @@ function runtest(::Type{TestRecord}, f, name, init_code)
195198 GC. gc (true )
196199 Random. seed! (1 )
197200
198- stats = @timed IOCapture. capture () do
201+ stats = @timed IOCapture. capture (; color = $ color ) do
199202 @testset $ name begin
200203 $ f
201204 end
@@ -654,7 +657,8 @@ function runtests(ARGS; testfilter = Returns(true), RecordType = TestRecord,
654657 # run the test
655658 put! (printer_channel, (:started , test, wrkr))
656659 result = try
657- remotecall_fetch (runtest, wrkr, RecordType, test_runners[test], test, init_code)
660+ remotecall_fetch (runtest, wrkr, RecordType, test_runners[test], test,
661+ init_code, io_ctx. color)
658662 catch ex
659663 if isa (ex, InterruptException)
660664 # the worker got interrupted, signal other tasks to stop
0 commit comments