Skip to content

Commit 9ad119c

Browse files
WIP add dryrun for printing out what test would be run
1 parent ab52516 commit 9ad119c

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
@@ -339,8 +339,14 @@ function _runtests_in_current_env(
339339
testitems, _ = include_testfiles!(proj_name, projectfile, paths, ti_filter, verbose_results, report)
340340
ntestitems = length(testitems.testitems)
341341
@debugv 1 "Done including tests in $paths"
342-
@info "Finished scanning for test items in $(round(time() - inc_time, digits=2)) seconds." *
343-
" Scheduling $ntestitems tests on pid $(Libc.getpid())" *
342+
@info "Finished scanning for test items in $(round(time() - inc_time, digits=2)) seconds."
343+
# TODO: make this a keyword to `runtests` that gets passed to `_runtests_in_current_env`
344+
dryrun = parse(Bool, get(ENV, "RETESTITEMS_DRYRUN", "false"))::Bool
345+
if dryrun
346+
print_testitems(testitems)
347+
return nothing
348+
end
349+
@info "Scheduling $ntestitems tests on pid $(Libc.getpid())" *
344350
(nworkers == 0 ? "" : " with $nworkers worker processes and $nworker_threads threads per worker.")
345351
try
346352
if nworkers == 0

src/testcontext.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,29 @@ end
106106

107107
TestItems(graph) = TestItems(graph, TestItem[], 0)
108108

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

0 commit comments

Comments
 (0)