Skip to content

Commit c7b6894

Browse files
WIP add dryrun for printing out what test would be run
1 parent 840cbff commit c7b6894

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

src/ReTestItems.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,14 @@ function _runtests_in_current_env(
376376
nworker_threads = cfg.nworker_threads
377377
ntestitems = length(testitems.testitems)
378378
@debugv 1 "Done including tests in $paths"
379-
@info "Finished scanning for test items in $(round(time() - inc_time, digits=2)) seconds." *
380-
" Scheduling $ntestitems tests on pid $(Libc.getpid())" *
379+
@info "Finished scanning for test items in $(round(time() - inc_time, digits=2)) seconds."
380+
# TODO: make this a keyword to `runtests` that gets passed to `_runtests_in_current_env`
381+
dryrun = parse(Bool, get(ENV, "RETESTITEMS_DRYRUN", "false"))::Bool
382+
if dryrun
383+
print_testitems(testitems)
384+
return nothing
385+
end
386+
@info "Scheduling $ntestitems tests on pid $(Libc.getpid())" *
381387
(nworkers == 0 ? "" : " with $nworkers worker processes and $nworker_threads threads per worker.")
382388
try
383389
if nworkers == 0

src/testcontext.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,29 @@ cancel!(t::TestItems) = @atomicswap t.cancelled = true
103103
# `cancel` and check the return value to know if they had already been cancelled.
104104
is_cancelled(t::TestItems) = @atomic t.cancelled
105105

106+
function print_testitems(tis::TestItems)
107+
ntestitems = length(tis.testitems)
108+
if ntestitems == 0
109+
printstyled("No test items found\n"; bold=true)
110+
return nothing
111+
end
112+
plural = ntestitems == 1 ? "" : "s"
113+
printstyled("$ntestitems test item$plural found:\n"; bold=true)
114+
print_testitems(tis.graph)
115+
end
116+
function print_testitems(dir::DirNode, indent::Int=0)
117+
println(" "^indent, dir.path)
118+
for child in dir.children
119+
print_testitems(child, indent + 1)
120+
end
121+
end
122+
function print_testitems(file::FileNode, indent::Int=0)
123+
println(" "^indent, file.path)
124+
for ti in file.testitems
125+
printstyled(" "^(indent+1), ti.name, "\n"; bold=true)
126+
end
127+
end
128+
106129
###
107130
### record results
108131
###

0 commit comments

Comments
 (0)