Skip to content

Commit b6628c8

Browse files
committed
marks: show also gray marks for un-shown children testsets
1 parent bd59157 commit b6628c8

File tree

2 files changed

+209
-54
lines changed

2 files changed

+209
-54
lines changed

src/ReTest.jl

Lines changed: 72 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ hasmany(tests) = length(tests) > 1 || isfor(tests[1])
13231323
function dryrun(mod::Module, ts::TestsetExpr, pat::Pattern, align::Int=0, parentsubj=""
13241324
; maxidw::Int, marks::Bool, # external calls
13251325
# only recursive calls:
1326-
evaldesc=true, repeated=nothing, ids::Vector{Int64}=Int64[])
1326+
evaldesc=true, repeated=nothing, ids::Vector{Int64}=Int64[], show::Bool=true)
13271327
@assert ts.run
13281328
desc = ts.desc
13291329

@@ -1341,37 +1341,80 @@ function dryrun(mod::Module, ts::TestsetExpr, pat::Pattern, align::Int=0, parent
13411341
subject = parentsubj * '/' * desc
13421342
if isfinal(ts) && !matches(pat, subject, ids)
13431343
pop!(ids)
1344-
return
1344+
return false, false, false
13451345
end
13461346
end
13471347

1348-
if maxidw > 0 # width (ndigits) of max id; <= 0 means ids not printed
1349-
printstyled(lpad(ts.id, maxidw), "| ", color = :light_black, bold=true)
1350-
end
1348+
res = get(ts.results, subject, nothing)
1349+
if show
1350+
if maxidw > 0 # width (ndigits) of max id; <= 0 means ids not printed
1351+
printstyled(lpad(ts.id, maxidw), "| ", color = :light_black, bold=true)
1352+
end
13511353

1352-
printstyled(' '^align, desc, color = desc isa String ? :normal : Base.warn_color())
1354+
printstyled(' '^align, desc, color = desc isa String ? :normal : Base.warn_color())
13531355

1354-
if repeated !== nothing
1355-
printstyled(" (repeated",
1356-
repeated == -1 ? ")" : " $repeated times)",
1357-
color=:light_black)
1358-
end
1356+
if repeated !== nothing
1357+
printstyled(" (repeated",
1358+
repeated == -1 ? ")" : " $repeated times)",
1359+
color=:light_black)
1360+
end
13591361

1360-
res = get(ts.results, subject, nothing)
1361-
if marks && res !== nothing
1362-
printstyled(res ? "" : "", color = res ? :green : Base.error_color(),
1363-
bold=true)
1362+
if marks && res !== nothing
1363+
printstyled(res ? "" : "", color = res ? :green : Base.error_color(),
1364+
bold=true)
1365+
end
13641366
end
1365-
println()
13661367

13671368
if ts.options.transient_verbose
1369+
@assert show
1370+
println()
1371+
for tsc in ts.children
1372+
tsc.run || continue
1373+
dryrun(mod, tsc, pat, align + 2, subject,
1374+
maxidw=maxidw, marks=marks, ids=ids, show=true)
1375+
end
1376+
pop!(ids)
1377+
false, false, false # meaningless unused triple
1378+
elseif marks
1379+
passes, fails, unrun = false, false, false
1380+
if !show
1381+
if res === nothing
1382+
unrun = true
1383+
elseif res
1384+
passes = true
1385+
else
1386+
fails = true
1387+
end
1388+
end
13681389
for tsc in ts.children
13691390
tsc.run || continue
1370-
dryrun(mod, tsc, pat, align + 2, subject, maxidw=maxidw, marks=marks, ids=ids)
1391+
cp, cf, cu = dryrun(mod, tsc, pat, align + 2, subject,
1392+
maxidw=maxidw, marks=marks, ids=ids, show=false)
1393+
passes |= cp
1394+
fails |= cf
1395+
unrun |= cu
1396+
passes && fails && unrun && break
13711397
end
1398+
pop!(ids)
1399+
if show
1400+
passes &&
1401+
printstyled("", color = :light_black, bold=true)
1402+
fails &&
1403+
printstyled("", color = :light_black, bold=true)
1404+
unrun &&
1405+
# space at the end because of a printing bug (with no trailing space,
1406+
# only two dots are printed instead of three on this machine)
1407+
printstyled("", color = :light_black, bold=true)
1408+
println()
1409+
end
1410+
passes, fails, unrun
1411+
else
1412+
if show
1413+
println()
1414+
end
1415+
pop!(ids)
1416+
false, false, false
13721417
end
1373-
pop!(ids)
1374-
nothing
13751418
else
13761419
function dryrun_beginend(descx, repeated=nothing)
13771420
# avoid repeating ourselves, transform this iteration into a "begin/end" testset
@@ -1395,7 +1438,7 @@ function dryrun(mod::Module, ts::TestsetExpr, pat::Pattern, align::Int=0, parent
13951438
beginend.id = ts.id
13961439
beginend.results = ts.results
13971440
dryrun(mod, beginend, pat, align, parentsubj; evaldesc=false,
1398-
repeated=repeated, maxidw=maxidw, marks=marks, ids=ids)
1441+
repeated=repeated, maxidw=maxidw, marks=marks, ids=ids, show=show)
13991442
end
14001443

14011444
loopvalues = ts.loopvalues
@@ -1417,6 +1460,7 @@ function dryrun(mod::Module, ts::TestsetExpr, pat::Pattern, align::Int=0, parent
14171460
end
14181461
dryrun_beginend(ts.desc, repeated)
14191462
else
1463+
passes, fails, unrun = false, false, false
14201464
for (i, x) in enumerate(loopvalues)
14211465
descx = eval_desc(mod, ts, x)
14221466
if descx === missing
@@ -1426,11 +1470,16 @@ function dryrun(mod::Module, ts::TestsetExpr, pat::Pattern, align::Int=0, parent
14261470
# so we add the "repeated" annotation
14271471
# (it's certainly not worth it to bother being more precise about
14281472
# exactly which iterations are uninterpolated)
1429-
return dryrun_beginend(ts.desc, length(loopvalues)-i+1)
1473+
lp, lf, lu = dryrun_beginend(ts.desc, length(loopvalues)-i+1)
1474+
else
1475+
lp, lf, lu = dryrun_beginend(descx)
14301476
end
1431-
@assert descx !== missing # should be unnecessary, but there was a test below
1432-
dryrun_beginend(descx)
1477+
passes |= lp
1478+
fails |= lf
1479+
unrun |= lu
1480+
descx === missing && break
14331481
end
1482+
passes, fails, unrun
14341483
end
14351484
end
14361485
end

test/runtests.jl

Lines changed: 137 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -879,48 +879,154 @@ using ReTest, ..Trace
879879
@test false
880880
end
881881
end
882+
882883
@testset "l$i" for i=1:2
883884
@testset "k$j" for j=1:2
884885
@test true
885886
end
886887
end
888+
889+
@testset "x" begin
890+
@testset "y$i" for i=1:2
891+
@testset "z1" begin
892+
@test true
893+
end
894+
@testset "z$j" for j=2:3
895+
@test true
896+
end
897+
@testset "z4" begin
898+
@test i == 1
899+
end
900+
end
887901
end
902+
end # Marks
888903

889904
@chapter Marks begin
890-
check(Marks, dry=true, marks=true, verbose=3, [], output=raw"""
891-
1| a
892-
2| b
893-
3| c
894-
4| "d$(x)"
895-
5| e
896-
6| l1
897-
7| k1
898-
7| k2
899-
6| l2
900-
7| k1
901-
7| k2
905+
check(Marks, "-x", dry=true, marks=true, verbose=3, id=false, [], output=raw"""
906+
a
907+
b
908+
c
909+
"d$(x)"
910+
e
911+
l1
912+
k1
913+
k2
914+
l2
915+
k1
916+
k2
917+
""")
918+
check(Marks, "-x", dry=true, marks=true, verbose=1, id=false, [], output=raw"""
919+
a ⋯
920+
l1 ⋯
921+
l2 ⋯
922+
""")
923+
retest(Marks, "-x", "k1")
924+
check(Marks, "-x", dry=true, marks=true, verbose=3, id=false, [], output=raw"""
925+
a ✅
926+
b
927+
c
928+
"d$(x)"
929+
e
930+
l1 ✅
931+
k1 ✅
932+
k2
933+
l2 ✅
934+
k1 ✅
935+
k2
902936
""")
903-
retest(Marks, "k1")
904-
check(Marks, dry=true, marks=true, verbose=3, [], output=raw"""
905-
1| a ✅
906-
2| b
907-
3| c
908-
4| "d$(x)"
909-
5| e
910-
6| l1 ✅
911-
7| k1 ✅
912-
7| k2
913-
6| l2 ✅
914-
7| k1 ✅
915-
7| k2
937+
check(Marks, "-x", dry=true, marks=true, verbose=1, id=false, [], output=raw"""
938+
a ✅ ⋯
939+
l1 ✅ ✅ ⋯
940+
l2 ✅ ✅ ⋯
916941
""")
917942
@test_throws Test.TestSetException retest(Marks, "e")
918-
check(Marks, "a", dry=true, marks=true, verbose=3, [], output=raw"""
919-
1| a ✅
920-
2| b
921-
3| c
922-
4| "d$(x)"
923-
5| e ✘
943+
check(Marks, "-x", "a", dry=true, marks=true, verbose=3, id=false, [], output=raw"""
944+
a ✅
945+
b
946+
c
947+
"d$(x)"
948+
e ✘
949+
""")
950+
check(Marks, "-x", "a", dry=true, marks=true, verbose=1, id=false, [], output=raw"""
951+
a ✅ ✘ ⋯
952+
""")
953+
retest(Marks, "b")
954+
check(Marks, "a", dry=true, marks=true, verbose=3, id=false, [], output=raw"""
955+
a ✅
956+
b ✅
957+
c
958+
"d$(x)"
959+
e ✘
960+
""")
961+
check(Marks, "a", dry=true, marks=true, verbose=1, id=false, [], output=raw"""
962+
a ✅ ✅ ✘ ⋯
963+
""")
964+
retest(Marks, "l2")
965+
check(Marks, "-x", dry=true, marks=true, verbose=3, id=false, [], output=raw"""
966+
a ✅
967+
b ✅
968+
c
969+
"d$(x)"
970+
e ✘
971+
l1 ✅
972+
k1 ✅
973+
k2
974+
l2 ✅
975+
k1 ✅
976+
k2 ✅
977+
""")
978+
check(Marks, "-x", dry=true, marks=true, verbose=1, id=false, [], output=raw"""
979+
a ✅ ✅ ✘ ⋯
980+
l1 ✅ ✅ ⋯
981+
l2 ✅ ✅
982+
""")
983+
984+
check(Marks, "x", dry=true, marks=true, verbose=3, id=false, interpolated, [], output="""
985+
x
986+
y1
987+
z1
988+
z2
989+
z3
990+
z4
991+
y2
992+
z1
993+
z2
994+
z3
995+
z4
996+
""")
997+
check(Marks, "x", dry=true, marks=true, verbose=2, id=false, interpolated, [], output="""
998+
x
999+
y1 ⋯
1000+
y2 ⋯
1001+
""")
1002+
retest(Marks, r"y1$")
1003+
# at record success at depth==2
1004+
check(Marks, "x", dry=true, marks=true, verbose=1, id=false, interpolated, [],
1005+
output="x ✅ ✅ ⋯")
1006+
@test_throws Test.TestSetException retest(Marks, "y2/z4")
1007+
check(Marks, "x", dry=true, marks=true, verbose=1, id=false, interpolated, [],
1008+
output="x ✅ ✅ ✘ ⋯")
1009+
@test_throws Test.TestSetException retest(Marks, "x")
1010+
check(Marks, "x", dry=true, marks=true, verbose=3, id=false, interpolated, [], output="""
1011+
x ✅
1012+
y1 ✅
1013+
z1 ✅
1014+
z2 ✅
1015+
z3 ✅
1016+
z4 ✅
1017+
y2 ✅
1018+
z1 ✅
1019+
z2 ✅
1020+
z3 ✅
1021+
z4 ✘
1022+
""")
1023+
check(Marks, "x", dry=true, marks=true, verbose=2, id=false, interpolated, [], output="""
1024+
x ✅
1025+
y1 ✅ ✅
1026+
y2 ✅ ✅ ✘
1027+
""")
1028+
check(Marks, "x", dry=true, marks=true, verbose=1, id=false, interpolated, [], output="""
1029+
x ✅ ✅ ✘
9241030
""")
9251031
end
9261032

0 commit comments

Comments
 (0)