Skip to content

Commit ca36072

Browse files
committed
retest: add experimental clear keyword, to clear marks
This can be useful when testing `ReTest` itself. It might also be useful in general, but let's wait for now before documenting this, the API might change.
1 parent fb0db68 commit ca36072

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/ReTest.jl

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ const retest_defaults = (
493493
seed = false,
494494
marks = true,
495495
spin = true,
496+
clear = false,
496497
)
497498

498499
def(kw::Symbol) =
@@ -653,6 +654,8 @@ function retest(@nospecialize(args::ArgType...);
653654
seed::Integer = def(:seed),
654655
marks::Bool = def(:marks),
655656
spin::Bool = def(:spin),
657+
# clear: clear marks for matching tests, only active if dry=true
658+
clear::Bool = def(:clear),
656659
)
657660

658661
dry, stats, shuffle, group, verbose, recursive, id, strict, dup, static, marks, spin =
@@ -712,7 +715,7 @@ function retest(@nospecialize(args::ArgType...);
712715
end
713716
if verbose > 0
714717
foreach(ts -> dryrun(mod, ts, pat, id ? 0 : module_header*2,
715-
maxidw = id ? maxidw[] : 0, marks=marks),
718+
maxidw = id ? maxidw[] : 0, marks=marks, clear=clear),
716719
tests)
717720
end
718721
continue
@@ -1389,7 +1392,7 @@ module_summary(verbose, many) = many | iszero(verbose)
13891392
hasmany(tests) = length(tests) > 1 || isfor(tests[1])
13901393

13911394
function dryrun(mod::Module, ts::TestsetExpr, pat::Pattern, align::Int=0, parentsubj=""
1392-
; maxidw::Int, marks::Bool, # external calls
1395+
; maxidw::Int, marks::Bool, clear::Bool, # external calls
13931396
# only recursive calls:
13941397
evaldesc=true, repeated=nothing, show::Bool=true)
13951398
@assert ts.run
@@ -1412,6 +1415,10 @@ function dryrun(mod::Module, ts::TestsetExpr, pat::Pattern, align::Int=0, parent
14121415
end
14131416

14141417
res = get(ts.pastresults, subject, nothing)
1418+
if clear && res !== nothing
1419+
delete!(ts.pastresults, subject)
1420+
end
1421+
14151422
if show
14161423
print_id(ts.id, maxidw)
14171424
printstyled(' '^align, desc, color = desc isa String ? :normal : Base.warn_color())
@@ -1434,7 +1441,7 @@ function dryrun(mod::Module, ts::TestsetExpr, pat::Pattern, align::Int=0, parent
14341441
for tsc in ts.children
14351442
tsc.run || continue
14361443
dryrun(mod, tsc, pat, align + 2, subject,
1437-
maxidw=maxidw, marks=marks, show=true)
1444+
maxidw=maxidw, marks=marks, clear=clear, show=true)
14381445
end
14391446
false, false, false # meaningless unused triple
14401447
elseif marks
@@ -1451,7 +1458,7 @@ function dryrun(mod::Module, ts::TestsetExpr, pat::Pattern, align::Int=0, parent
14511458
for tsc in ts.children
14521459
tsc.run || continue
14531460
cp, cf, cu = dryrun(mod, tsc, pat, align + 2, subject,
1454-
maxidw=maxidw, marks=marks, show=false)
1461+
maxidw=maxidw, marks=marks, clear=clear, show=false)
14551462
passes |= cp
14561463
fails |= cf
14571464
unrun |= cu
@@ -1498,7 +1505,7 @@ function dryrun(mod::Module, ts::TestsetExpr, pat::Pattern, align::Int=0, parent
14981505
beginend.id = ts.id
14991506
beginend.pastresults = ts.pastresults
15001507
dryrun(mod, beginend, pat, align, parentsubj; evaldesc=false,
1501-
repeated=repeated, maxidw=maxidw, marks=marks, show=show)
1508+
repeated=repeated, maxidw=maxidw, marks=marks, clear=clear, show=show)
15021509
end
15031510

15041511
loopvalues = ts.loopvalues

0 commit comments

Comments
 (0)