Skip to content

Commit 09b20e3

Browse files
committed
retest: add spin keyword to control previewing with spinner
1 parent 5249d93 commit 09b20e3

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/ReTest.jl

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ const ArgType = Union{Module,PatternX,AbstractString,AbstractArray,Tuple,Symbol,
484484
[id::Bool], shuffle::Bool=false, recursive::Bool=true,
485485
static::Union{Bool,Nothing}=nothing, dup::Bool=false,
486486
load::Bool=false, seed::Union{Integer,Bool}=false,
487-
marks::Bool=true)
487+
marks::Bool=true, spin::Bool=true)
488488
489489
Run tests declared with [`@testset`](@ref) blocks, within modules `mod` if specified,
490490
or within all currently loaded modules otherwise.
@@ -528,6 +528,12 @@ Filtering `pattern`s can be specified to run only a subset of the tests.
528528
is performed, and if `seed === true`, a seed is chosen randomly.
529529
* When `marks` and `dry` are `true`, "check marks" are printed next to testsets
530530
which passed or failed in previous runs.
531+
* When `spin` is `true`, the description of the testset being currently executed
532+
is shown (if there is only one), as well as a "spinner". This is disabled when
533+
all the available threads/workers are used to run tests (i.e. typically
534+
`Threads.nthreads()` should be greater than `1` for `spin` to take effect).
535+
Note also that this feature slows down a bit the execution of tests.
536+
531537
532538
### Filtering
533539
@@ -615,10 +621,11 @@ function retest(@nospecialize(args::ArgType...);
615621
load::Bool=false,
616622
seed::Integer=false,
617623
marks::Bool=true,
624+
spin::Bool=true,
618625
)
619626

620-
dry, stats, shuffle, group, verbose, recursive, id, strict, dup, static, marks =
621-
update_keywords(args, dry, stats, shuffle, group, verbose, recursive, id, strict, dup, static, marks)
627+
dry, stats, shuffle, group, verbose, recursive, id, strict, dup, static, marks, spin =
628+
update_keywords(args, dry, stats, shuffle, group, verbose, recursive, id, strict, dup, static, marks, spin)
622629

623630
implicitmodules, modules, verbose = process_args(args; verbose=verbose, shuffle=shuffle,
624631
recursive=recursive, load=load)
@@ -724,7 +731,8 @@ function retest(@nospecialize(args::ArgType...);
724731

725732
printlock = ReentrantLock()
726733
previewchan =
727-
if stdout isa Base.TTY && (nthreads() > 1 && VERSION >= v"1.3" || nprocs() > 1)
734+
if spin && stdout isa Base.TTY && (nthreads() > 1 && VERSION >= v"1.3" ||
735+
nprocs() > 1)
728736
RemoteChannel(() -> Channel{Maybe{Tuple{Int64,String}}}(Inf))
729737
# needs to be "remote" in the case nprocs() == 2, as then nworkers() == 1,
730738
# which means the one remote worker will put descriptions on previewchan
@@ -1056,7 +1064,7 @@ end
10561064

10571065
# hidden feature, shortcuts for passing kwargs to retest
10581066
function update_keywords(@nospecialize(args), dry, stats, shuffle, group, verbose,
1059-
recursive, id, strict, dup, static, marks)
1067+
recursive, id, strict, dup, static, marks, spin)
10601068
for arg in args
10611069
if arg isa Symbol
10621070
for c in string(arg)
@@ -1085,13 +1093,15 @@ function update_keywords(@nospecialize(args), dry, stats, shuffle, group, verbos
10851093
static = val
10861094
elseif c == 'm'
10871095
marks = val
1096+
elseif c == 'p'
1097+
spin = val
10881098
else
10891099
error("bad keyword shortcut")
10901100
end
10911101
end
10921102
end
10931103
end
1094-
dry, stats, shuffle, group, verbose, recursive, id, strict, dup, static, marks
1104+
dry, stats, shuffle, group, verbose, recursive, id, strict, dup, static, marks, spin
10951105
end
10961106

10971107
function process_args(@nospecialize(args);

0 commit comments

Comments
 (0)