Skip to content

Commit

Permalink
runtests: Print currently running tests when asked (#34212)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Keno authored Dec 29, 2019
1 parent 0570202 commit 4c67921
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,24 @@ cd(@__DIR__) do
try
# Monitor stdin and kill this task on ^C
# but don't do this on Windows, because it may deadlock in the kernel
running_tests = Dict{String, DateTime}()
if !Sys.iswindows() && isa(stdin, Base.TTY)
t = current_task()
stdin_monitor = @async begin
term = REPL.Terminals.TTYTerminal("xterm", stdin, stdout, stderr)
try
REPL.Terminals.raw!(term, true)
while true
if read(term, Char) == '\x3'
c = read(term, Char)
if c == '\x3'
Base.throwto(t, InterruptException())
break
elseif c == '?'
println("Currently running: ")
tests = sort(collect(running_tests), by=x->x[2])
foreach(tests) do (test, date)
println(test, " (running for ", round(now()-date, Minute), ")")
end
end
end
catch e
Expand All @@ -180,6 +188,7 @@ cd(@__DIR__) do
push!(all_tasks, current_task())
while length(tests) > 0
test = popfirst!(tests)
running_tests[test] = now()
local resp
wrkr = p
try
Expand All @@ -188,6 +197,7 @@ cd(@__DIR__) do
isa(e, InterruptException) && return
resp = Any[e]
end
delete!(running_tests, test)
push!(results, (test, resp))
if resp[1] isa Exception
print_testworker_errored(test, wrkr)
Expand Down

0 comments on commit 4c67921

Please sign in to comment.