Skip to content

Commit 1608595

Browse files
committed
dryrun: filter isfinal testsets even with unknown subjects
I.e. a testset can have a `missing` subject, but still have to be filtered out: e.g. with a "duplicity" loop, in the face of the `iter(n)` pattern (see added tests for details).
1 parent dbb0a40 commit 1608595

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

src/ReTest.jl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,8 @@ module_summary(verbose, many) = many | iszero(verbose)
14521452
# FIXME: isfor when only one iteration
14531453
hasmany(tests) = length(tests) > 1 || isfor(tests[1])
14541454

1455-
function dryrun(mod::Module, ts::TestsetExpr, pat::Pattern, align::Int=0, parentsubj=""
1455+
function dryrun(mod::Module, ts::TestsetExpr, pat::Pattern, align::Int=0,
1456+
parentsubj::Union{Missing, String}=""
14561457
; maxidw::Int, marks::Bool, clear::Bool, # external calls
14571458
# only recursive calls:
14581459
evaldesc=true, repeated=nothing, show::Bool=true)
@@ -1467,12 +1468,10 @@ function dryrun(mod::Module, ts::TestsetExpr, pat::Pattern, align::Int=0, parent
14671468
end
14681469
end
14691470

1470-
subject = nothing
1471-
if parentsubj isa String && desc isa String
1472-
subject = parentsubj * '/' * desc
1473-
if isfinal(ts) && !matches(pat, subject, ts)
1474-
return false, false, false
1475-
end
1471+
subject = desc isa String ? parentsubj * "/" * desc :
1472+
missing
1473+
if isfinal(ts) && false === matches(pat, subject, ts)
1474+
return false, false, false
14761475
end
14771476

14781477
res = pastresult(ts.marks, subject)

test/runtests.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,18 @@ a
789789
"b?" (repeated 1 times)
790790
c
791791
""")
792+
793+
# in dryrun mode, isfinal testsets might have to be filtered out even when
794+
# their description can't be interpolated (finding such an example was initial
795+
# motivation to add the iter(n)::Iter pattern)
796+
check(MiscDuplicity, (2, iter(1)), dry=true, id=false, verbose=2, [], output="""
797+
a
798+
b1
799+
""")
800+
check(MiscDuplicity, (2, iter(2)), dry=true, id=false, verbose=2, [], output="""
801+
a
802+
"b?" (repeated 1 times)
803+
""")
792804
end
793805

794806
module MV # MiscVerbose, but we want the name to be short to not have effect on alignment

0 commit comments

Comments
 (0)