Skip to content

Commit 4c67921

Browse files
authored
runtests: Print currently running tests when asked (#34212)
With this patch, pressing '?' while the test are running will print which tests are still running. Of course, you could just try to look through the log to try to figure out which tests have started but not yet finished, but that's pretty annoying to do. Being able to just ask is much easier for the impatient developer.
1 parent 0570202 commit 4c67921

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

test/runtests.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,24 @@ cd(@__DIR__) do
155155
try
156156
# Monitor stdin and kill this task on ^C
157157
# but don't do this on Windows, because it may deadlock in the kernel
158+
running_tests = Dict{String, DateTime}()
158159
if !Sys.iswindows() && isa(stdin, Base.TTY)
159160
t = current_task()
160161
stdin_monitor = @async begin
161162
term = REPL.Terminals.TTYTerminal("xterm", stdin, stdout, stderr)
162163
try
163164
REPL.Terminals.raw!(term, true)
164165
while true
165-
if read(term, Char) == '\x3'
166+
c = read(term, Char)
167+
if c == '\x3'
166168
Base.throwto(t, InterruptException())
167169
break
170+
elseif c == '?'
171+
println("Currently running: ")
172+
tests = sort(collect(running_tests), by=x->x[2])
173+
foreach(tests) do (test, date)
174+
println(test, " (running for ", round(now()-date, Minute), ")")
175+
end
168176
end
169177
end
170178
catch e
@@ -180,6 +188,7 @@ cd(@__DIR__) do
180188
push!(all_tasks, current_task())
181189
while length(tests) > 0
182190
test = popfirst!(tests)
191+
running_tests[test] = now()
183192
local resp
184193
wrkr = p
185194
try
@@ -188,6 +197,7 @@ cd(@__DIR__) do
188197
isa(e, InterruptException) && return
189198
resp = Any[e]
190199
end
200+
delete!(running_tests, test)
191201
push!(results, (test, resp))
192202
if resp[1] isa Exception
193203
print_testworker_errored(test, wrkr)

0 commit comments

Comments
 (0)