@@ -14,7 +14,7 @@ using Distributed: myid, nworkers
14
14
15
15
import InlineTest: @testset
16
16
17
- using .. ReTest: Pattern, matches
17
+ using .. ReTest: Pattern, matches, setresult
18
18
19
19
# mostly copied from Test stdlib
20
20
# changed from Test: pass nothing as file in ip_has_file_and_func
@@ -65,7 +65,7 @@ mutable struct ReTestSet <: AbstractTestSet
65
65
subject:: String
66
66
id:: Int64
67
67
overall:: Bool # TODO : could be conveyed by having self.mod == ""
68
- pastresults :: Dict{String,Bool}
68
+ marks :: Dict{String, Union{Symbol, Vector{Symbol}}} # used in matches()
69
69
results:: Vector
70
70
n_passed:: Int
71
71
anynonpass:: Bool
76
76
77
77
function ReTestSet (mod, desc:: String , id:: Integer = 0 ;
78
78
overall= false , verbose= true , parent= nothing ,
79
- pastresults = Dict {String,Bool } ())
79
+ marks = Dict {String, Union{Symbol, Vector{Symbol}} } ())
80
80
parentsubj = parent === nothing ? " " : parent. subject
81
81
subject = string (parentsubj, ' /' , desc)
82
- ReTestSet (mod, parent, desc, subject, id, overall, pastresults , [],
82
+ ReTestSet (mod, parent, desc, subject, id, overall, marks , [],
83
83
0 , false , verbose, NamedTuple (), nothing )
84
84
end
85
85
@@ -447,11 +447,11 @@ default_rng() = isdefined(Random, :default_rng) ?
447
447
Random. default_rng () :
448
448
Random. GLOBAL_RNG
449
449
450
- function make_retestset (mod, desc, id, verbose, pastresults , remove_last= false )
450
+ function make_retestset (mod, desc, id, verbose, marks , remove_last= false )
451
451
_testsets = get (task_local_storage (), :__BASETESTNEXT__ , Test. AbstractTestSet[])
452
452
@assert ! (remove_last && isempty (_testsets))
453
453
testsets = @view _testsets[1 : end - remove_last]
454
- ReTestSet (mod, desc, id; verbose= verbose, pastresults = pastresults ,
454
+ ReTestSet (mod, desc, id; verbose= verbose, marks = marks ,
455
455
parent = isempty (testsets) ? nothing : testsets[end ])
456
456
end
457
457
@@ -472,30 +472,30 @@ end
472
472
473
473
# non-inline testset with regex filtering support
474
474
macro testset (mod:: Module , isfinal:: Bool , pat:: Pattern , id:: Int64 , desc:: Union{String,Expr} ,
475
- options, pastresults :: Dict , stats:: Bool , chan, body)
475
+ options, marks :: Dict , stats:: Bool , chan, body)
476
476
Testset. testset_beginend (mod, isfinal, pat, id, desc,
477
- options, pastresults , stats, chan, body, __source__)
477
+ options, marks , stats, chan, body, __source__)
478
478
end
479
479
480
480
macro testset (mod:: Module , isfinal:: Bool , pat:: Pattern , id:: Int64 , desc:: Union{String,Expr} ,
481
- options, pastresults :: Dict , stats:: Bool , chan, loops, body)
481
+ options, marks :: Dict , stats:: Bool , chan, loops, body)
482
482
Testset. testset_forloop (mod, isfinal, pat, id, desc,
483
- options, pastresults , stats, chan, loops, body, __source__)
483
+ options, marks , stats, chan, loops, body, __source__)
484
484
end
485
485
486
486
"""
487
487
Generate the code for a `@testset` with a `begin`/`end` argument
488
488
"""
489
489
function testset_beginend (mod:: Module , isfinal:: Bool , pat:: Pattern , id:: Int64 , desc, options,
490
- pastresults :: Dict , stats:: Bool , chan, tests, source)
490
+ marks :: Dict , stats:: Bool , chan, tests, source)
491
491
# Generate a block of code that initializes a new testset, adds
492
492
# it to the task local storage, evaluates the test(s), before
493
493
# finally removing the testset and giving it a chance to take
494
494
# action (such as reporting the results)
495
495
desc = esc (desc)
496
496
ex = quote
497
497
local ts = make_retestset ($ mod, $ desc, $ id, $ (options. transient_verbose),
498
- $ pastresults )
498
+ $ marks )
499
499
500
500
if ! $ isfinal || matches ($ pat, ts. subject, ts)
501
501
local ret
@@ -526,7 +526,7 @@ function testset_beginend(mod::Module, isfinal::Bool, pat::Pattern, id::Int64, d
526
526
Base. catch_stack (), $ (QuoteNode (source))))
527
527
finally
528
528
copy! (RNG, oldrng)
529
- $ pastresults[ ts. subject] = ! anyfailed (ts)
529
+ setresult ( $ marks, ts. subject, ! anyfailed (ts) )
530
530
pop_testset ()
531
531
ret = finish (ts, $ chan)
532
532
end
@@ -546,13 +546,13 @@ end
546
546
Generate the code for a `@testset` with a `for` loop argument
547
547
"""
548
548
function testset_forloop (mod:: Module , isfinal:: Bool , pat:: Pattern , id:: Int64 ,
549
- desc:: Union{String,Expr} , options, pastresults :: Dict , stats, chan,
549
+ desc:: Union{String,Expr} , options, marks :: Dict , stats, chan,
550
550
loops, tests, source)
551
551
552
552
desc = esc (desc)
553
553
blk = quote
554
554
local ts0 = make_retestset ($ mod, $ desc, $ id, $ (options. transient_verbose),
555
- $ pastresults , ! first_iteration)
555
+ $ marks , ! first_iteration)
556
556
557
557
if ! $ isfinal || matches ($ pat, ts0. subject, ts0)
558
558
# Trick to handle `break` and `continue` in the test code before
@@ -573,13 +573,13 @@ function testset_forloop(mod::Module, isfinal::Bool, pat::Pattern, id::Int64,
573
573
let
574
574
ts. timed = @stats $ stats $ (esc (tests))
575
575
end
576
- $ pastresults[ ts. subject] = ! anyfailed (ts)
576
+ setresult ( $ marks, ts. subject, ! anyfailed (ts) )
577
577
catch err
578
578
err isa InterruptException && rethrow ()
579
579
# Something in the test block threw an error. Count that as an
580
580
# error in this test set
581
581
record (ts, Error (:nontest_error , Expr (:tuple ), err, Base. catch_stack (), $ (QuoteNode (source))))
582
- $ pastresults[ ts. subject] = false
582
+ setresult ( $ marks, ts. subject, false )
583
583
end
584
584
end
585
585
end
0 commit comments