90
90
isfor (ts:: TestsetExpr ) = ts. loops != = nothing
91
91
isfinal (ts:: TestsetExpr ) = isempty (ts. children)
92
92
93
+ function tsdepth (ts:: Union{TestsetExpr,Testset.ReTestSet} )
94
+ d = 1
95
+ while ts. parent != = nothing
96
+ d += 1
97
+ ts = ts. parent
98
+ end
99
+ d
100
+ end
101
+
93
102
struct _Invalid
94
103
global const invalid = _Invalid. instance
95
104
end
215
224
function resolve! (mod:: Module , ts:: TestsetExpr , pat:: Pattern ;
216
225
# external calls
217
226
verbose:: Int , id:: Int64 , strict:: Bool , static:: Maybe{Bool} ,
218
- ids :: Vector{Int64} , warned:: Ref{Bool} ,
227
+ warned:: Ref{Bool} ,
219
228
# only recursive calls
220
229
force:: Bool = false , shown:: Bool = true , depth:: Int = 0 )
221
230
@@ -229,9 +238,8 @@ function resolve!(mod::Module, ts::TestsetExpr, pat::Pattern;
229
238
warned[] = true
230
239
end
231
240
ts. id = id
232
- push! (ids, id)
233
241
id += 1
234
- ts. run = force | (static != = false ) & alwaysmatches (pat, length (ids ))
242
+ ts. run = force | (static != = false ) & alwaysmatches (pat, tsdepth (ts ))
235
243
236
244
parentstrs = ts. parent === nothing ? [" " ] : ts. parent. strings
237
245
ts. descwidth = 0
@@ -256,7 +264,7 @@ function resolve!(mod::Module, ts::TestsetExpr, pat::Pattern;
256
264
end
257
265
258
266
function decide (subj)
259
- m = matches (pat, subj, ids )
267
+ m = matches (pat, subj, ts )
260
268
# For the curious reader, setting `s = something(static, missing)`, there
261
269
# are few "formulas" to compute the result without `if`, but using only
262
270
# `coalesce, |, &, ==, !=, ===, !==, (a,b) -> a, (a,b) -> b, (a,b) -> !a,
@@ -367,15 +375,14 @@ function resolve!(mod::Module, ts::TestsetExpr, pat::Pattern;
367
375
runc, id = resolve! (mod, tsc, pat, force = ! strict && ts. run,
368
376
shown= shown & ts. options. transient_verbose, static= static,
369
377
depth= depth+ 1 , verbose= verbose- 1 , id= id, strict= strict,
370
- ids = ids, warned= warned)
378
+ warned= warned)
371
379
run |= runc
372
380
ts. descwidth = max (ts. descwidth, tsc. descwidth)
373
381
if tsc. run
374
382
ts. hasbrokenrec |= tsc. hasbrokenrec
375
383
end
376
384
end
377
385
378
- pop! (ids)
379
386
if ! run || ! shown
380
387
ts. descwidth = 0
381
388
end
@@ -1285,12 +1292,11 @@ function fetchtests((mod, pat), verbose, module_header, maxidw; static, strict,
1285
1292
hasbroken = false
1286
1293
1287
1294
id = 1
1288
- ids = Int64[]
1289
1295
warned = Ref (false )
1290
1296
1291
1297
for ts in tests
1292
1298
run, id = resolve! (mod, ts, pat, verbose= verbose, id= id, strict= strict,
1293
- static= static, ids = ids, warned= warned)
1299
+ static= static, warned= warned)
1294
1300
run || continue
1295
1301
descwidth = max (descwidth, ts. descwidth)
1296
1302
hasbroken |= ts. hasbrokenrec
@@ -1323,12 +1329,11 @@ hasmany(tests) = length(tests) > 1 || isfor(tests[1])
1323
1329
function dryrun (mod:: Module , ts:: TestsetExpr , pat:: Pattern , align:: Int = 0 , parentsubj= " "
1324
1330
; maxidw:: Int , marks:: Bool , # external calls
1325
1331
# only recursive calls:
1326
- evaldesc= true , repeated= nothing , ids :: Vector{Int64} = Int64[], show:: Bool = true )
1332
+ evaldesc= true , repeated= nothing , show:: Bool = true )
1327
1333
@assert ts. run
1328
1334
desc = ts. desc
1329
1335
1330
1336
if ts. loops === nothing
1331
- push! (ids, ts. id)
1332
1337
if evaldesc && ! (desc isa String)
1333
1338
try
1334
1339
desc = Core. eval (mod, desc)
@@ -1339,8 +1344,7 @@ function dryrun(mod::Module, ts::TestsetExpr, pat::Pattern, align::Int=0, parent
1339
1344
subject = nothing
1340
1345
if parentsubj isa String && desc isa String
1341
1346
subject = parentsubj * ' /' * desc
1342
- if isfinal (ts) && ! matches (pat, subject, ids)
1343
- pop! (ids)
1347
+ if isfinal (ts) && ! matches (pat, subject, ts)
1344
1348
return false , false , false
1345
1349
end
1346
1350
end
@@ -1371,9 +1375,8 @@ function dryrun(mod::Module, ts::TestsetExpr, pat::Pattern, align::Int=0, parent
1371
1375
for tsc in ts. children
1372
1376
tsc. run || continue
1373
1377
dryrun (mod, tsc, pat, align + 2 , subject,
1374
- maxidw= maxidw, marks= marks, ids = ids, show= true )
1378
+ maxidw= maxidw, marks= marks, show= true )
1375
1379
end
1376
- pop! (ids)
1377
1380
false , false , false # meaningless unused triple
1378
1381
elseif marks
1379
1382
passes, fails, unrun = false , false , false
@@ -1389,13 +1392,12 @@ function dryrun(mod::Module, ts::TestsetExpr, pat::Pattern, align::Int=0, parent
1389
1392
for tsc in ts. children
1390
1393
tsc. run || continue
1391
1394
cp, cf, cu = dryrun (mod, tsc, pat, align + 2 , subject,
1392
- maxidw= maxidw, marks= marks, ids = ids, show= false )
1395
+ maxidw= maxidw, marks= marks, show= false )
1393
1396
passes |= cp
1394
1397
fails |= cf
1395
1398
unrun |= cu
1396
1399
passes && fails && unrun && break
1397
1400
end
1398
- pop! (ids)
1399
1401
if show
1400
1402
passes &&
1401
1403
printstyled (" ✅" , color = :light_black , bold= true )
@@ -1412,7 +1414,6 @@ function dryrun(mod::Module, ts::TestsetExpr, pat::Pattern, align::Int=0, parent
1412
1414
if show
1413
1415
println ()
1414
1416
end
1415
- pop! (ids)
1416
1417
false , false , false
1417
1418
end
1418
1419
else
@@ -1438,7 +1439,7 @@ function dryrun(mod::Module, ts::TestsetExpr, pat::Pattern, align::Int=0, parent
1438
1439
beginend. id = ts. id
1439
1440
beginend. results = ts. results
1440
1441
dryrun (mod, beginend, pat, align, parentsubj; evaldesc= false ,
1441
- repeated= repeated, maxidw= maxidw, marks= marks, ids = ids, show= show)
1442
+ repeated= repeated, maxidw= maxidw, marks= marks, show= show)
1442
1443
end
1443
1444
1444
1445
loopvalues = ts. loopvalues
0 commit comments