Skip to content

Commit aa8ad2b

Browse files
WIP add dryrun for printing out what test would be run
1 parent e8295b0 commit aa8ad2b

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

Diff for: src/ReTestItems.jl

+8-2
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,14 @@ function _runtests_in_current_env(
332332
testitems, _ = include_testfiles!(proj_name, projectfile, paths, ti_filter, verbose_results, report)
333333
ntestitems = length(testitems.testitems)
334334
@debugv 1 "Done including tests in $paths"
335-
@info "Finished scanning for test items in $(round(time() - inc_time, digits=2)) seconds." *
336-
" Scheduling $ntestitems tests on pid $(Libc.getpid())" *
335+
@info "Finished scanning for test items in $(round(time() - inc_time, digits=2)) seconds."
336+
# TODO: make this a keyword to `runtests` that gets passed to `_runtests_in_current_env`
337+
dryrun = parse(Bool, get(ENV, "RETESTITEMS_DRYRUN", "false"))::Bool
338+
if dryrun
339+
print_testitems(testitems)
340+
return nothing
341+
end
342+
@info "Scheduling $ntestitems tests on pid $(Libc.getpid())" *
337343
(nworkers == 0 ? "" : " with $nworkers worker processes and $nworker_threads threads per worker.")
338344
try
339345
if nworkers == 0

Diff for: src/testcontext.jl

+23
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,29 @@ end
9494

9595
TestItems(graph) = TestItems(graph, TestItem[], 0)
9696

97+
function print_testitems(tis::TestItems)
98+
ntestitems = length(tis.testitems)
99+
if ntestitems == 0
100+
printstyled("No test items found\n"; bold=true)
101+
return nothing
102+
end
103+
plural = ntestitems == 1 ? "" : "s"
104+
printstyled("$ntestitems test item$plural found:\n"; bold=true)
105+
print_testitems(tis.graph)
106+
end
107+
function print_testitems(dir::DirNode, indent::Int=0)
108+
println(" "^indent, dir.path)
109+
for child in dir.children
110+
print_testitems(child, indent + 1)
111+
end
112+
end
113+
function print_testitems(file::FileNode, indent::Int=0)
114+
println(" "^indent, file.path)
115+
for ti in file.testitems
116+
printstyled(" "^(indent+1), ti.name, "\n"; bold=true)
117+
end
118+
end
119+
97120
###
98121
### record results
99122
###

0 commit comments

Comments
 (0)