7777
7878@testset " custom testrecord" begin
7979 custom_record_init = quote
80+ import ParallelTestRunner: Test
8081 struct CustomTestRecord <: ParallelTestRunner.AbstractTestRecord
8182 # TODO : Would it be better to wrap "ParallelTestRunner.TestRecord "
8283 value:: Any # AbstractTestSet or TestSetException
9192 function ParallelTestRunner. memory_usage (rec:: CustomTestRecord )
9293 return rec. rss
9394 end
94- function ParallelTestRunner. test_IOContext (:: Type{CustomTestRecord} , args ... )
95- return ParallelTestRunner. test_IOContext (ParallelTestRunner. TestRecord, args ... )
95+ function ParallelTestRunner. test_IOContext (:: Type{CustomTestRecord} , stdout :: IO , stderr :: IO , lock :: ReentrantLock , name_align :: Int64 )
96+ return ParallelTestRunner. test_IOContext (ParallelTestRunner. TestRecord, stdout , stderr , lock, name_align )
9697 end
9798 function ParallelTestRunner. runtest (:: Type{CustomTestRecord} , f, name, init_code, color, (; say_hello))
9899 function inner ()
99100 # generate a temporary module to execute the tests in
100- mod = @ eval (Main, module $ ( gensym (name)) end )
101+ mod = Core . eval (Main, Expr ( : module, true , gensym (name), Expr ( :block )) )
101102 @eval (mod, import ParallelTestRunner: Test, Random)
102103 @eval (mod, using . Test, . Random)
103104
@@ -110,11 +111,12 @@ end
110111 mktemp () do path, io
111112 stats = redirect_stdio (stdout = io, stderr = io) do
112113 @timed try
113- if say_hello
114- println (" Hello from test '$name '" )
114+ # Since we are in a double quote we need to use this form to escape `$`
115+ if $ (Expr (:$ , :say_hello ))
116+ println (" Hello from test '" * $ (Expr (:$ , :name )) * " '" )
115117 end
116- @testset $ name begin
117- $ f
118+ @testset $ ( Expr ( :$ , : name)) begin
119+ $ ( Expr ( :$ , :f ))
118120 end
119121 catch err
120122 isa (err, Test. TestSetException) || rethrow ()
132134
133135 # process results
134136 rss = Sys. maxrss ()
135- record = TestRecord (data... , rss)
137+ record = CustomTestRecord (data... , rss)
136138
137139 GC. gc (true )
138140 return record
0 commit comments