Skip to content

Commit

Permalink
WIP add dryrun for printing out what test would be run
Browse files Browse the repository at this point in the history
  • Loading branch information
nickrobinson251 committed Aug 21, 2024
1 parent ab52516 commit 9ad119c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/ReTestItems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,14 @@ function _runtests_in_current_env(
testitems, _ = include_testfiles!(proj_name, projectfile, paths, ti_filter, verbose_results, report)
ntestitems = length(testitems.testitems)
@debugv 1 "Done including tests in $paths"
@info "Finished scanning for test items in $(round(time() - inc_time, digits=2)) seconds." *
" Scheduling $ntestitems tests on pid $(Libc.getpid())" *
@info "Finished scanning for test items in $(round(time() - inc_time, digits=2)) seconds."
# TODO: make this a keyword to `runtests` that gets passed to `_runtests_in_current_env`
dryrun = parse(Bool, get(ENV, "RETESTITEMS_DRYRUN", "false"))::Bool
if dryrun
print_testitems(testitems)
return nothing
end
@info "Scheduling $ntestitems tests on pid $(Libc.getpid())" *
(nworkers == 0 ? "" : " with $nworkers worker processes and $nworker_threads threads per worker.")
try
if nworkers == 0
Expand Down
23 changes: 23 additions & 0 deletions src/testcontext.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,29 @@ end

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

function print_testitems(tis::TestItems)
ntestitems = length(tis.testitems)
if ntestitems == 0
printstyled("No test items found\n"; bold=true)
return nothing
end
plural = ntestitems == 1 ? "" : "s"
printstyled("$ntestitems test item$plural found:\n"; bold=true)
print_testitems(tis.graph)
end
function print_testitems(dir::DirNode, indent::Int=0)
println(" "^indent, dir.path)
for child in dir.children
print_testitems(child, indent + 1)
end
end
function print_testitems(file::FileNode, indent::Int=0)
println(" "^indent, file.path)
for ti in file.testitems
printstyled(" "^(indent+1), ti.name, "\n"; bold=true)
end
end

###
### record results
###
Expand Down

0 comments on commit 9ad119c

Please sign in to comment.