@@ -13,6 +13,9 @@ include("choosetests.jl")
1313include (" testenv.jl" 
1414include (" buildkitetestjson.jl" 
1515
16+ const  longrunning_delay =  parse (Int, get (ENV , " JULIA_TEST_LONGRUNNING_DELAY" " 45" *  60  #  minutes
17+ const  longrunning_interval =  parse (Int, get (ENV , " JULIA_TEST_LONGRUNNING_INTERVAL" " 15" *  60  #  minutes
18+ 
1619(; tests, net_on, exit_on_error, use_revise, buildroot, seed) =  choosetests (ARGS )
1720tests =  unique (tests)
1821
@@ -188,10 +191,10 @@ cd(@__DIR__) do
188191        at =  lpad (" ($wrkr )" -  textwidth (name) +  1 , "  " 
189192        lock (print_lock)
190193        try 
191-             printstyled (name, at, "  |" "  " ^ elapsed_align,
192-                      " started at $(now ()) " 
194+             printstyled (name, at, "  |" "  " ^ elapsed_align, color = :white ) 
195+             printstyled ( " started at $(now ()) " 
193196                    (pid >  0  ?  "  on pid $pid " :  " " 
194-                     " \n " = :white  )
197+                     " \n " = :light_black  )
195198        finally 
196199            unlock (print_lock)
197200        end 
@@ -228,6 +231,10 @@ cd(@__DIR__) do
228231        #  Monitor stdin and kill this task on ^C
229232        #  but don't do this on Windows, because it may deadlock in the kernel
230233        running_tests =  Dict {String, DateTime} ()
234+ 
235+         #  Track timeout timers for each test
236+         test_timers =  Dict {String, Timer} ()
237+ 
231238        if  ! Sys. iswindows () &&  isa (stdin , Base. TTY)
232239            t =  current_task ()
233240            stdin_monitor =  @async  begin 
@@ -262,6 +269,33 @@ cd(@__DIR__) do
262269                        test =  popfirst! (tests)
263270                        running_tests[test] =  now ()
264271                        wrkr =  p
272+ 
273+                         #  Create a timer for this test to report long-running status
274+                         test_timers[test] =  Timer (longrunning_delay, interval= longrunning_interval) do  timer
275+                             if  haskey (running_tests, test)  #  Check test is still running
276+                                 start_time =  running_tests[test]
277+                                 elapsed =  now () -  start_time
278+                                 elapsed_minutes =  elapsed. value ÷  (1000  *  60 )
279+ 
280+                                 elapsed_str =  if  elapsed_minutes >=  60 
281+                                     hours, mins =  divrem (elapsed_minutes, 60 )
282+                                     " $(hours) h $(mins) m" 
283+                                 else 
284+                                     " $(elapsed_minutes) m" 
285+                                 end 
286+ 
287+                                 @lock  print_lock begin 
288+                                     print (test)
289+                                     print (lpad (" ($(wrkr) )" -  textwidth (test) +  1 , "  " "  | " 
290+                                     #  Calculate total width of data columns: "Time (s) | GC (s) | GC % | Alloc (MB) | RSS (MB)"
291+                                     #  This is: elapsed_align + 3 + gc_align + 3 + percent_align + 3 + alloc_align + 3 + rss_align
292+                                     data_width =  elapsed_align +  gc_align +  percent_align +  alloc_align +  rss_align +  12   #  12 = 4 * " | "
293+                                     message =  " has been running for $(elapsed_str) " 
294+                                     centered_message =  lpad (rpad (message, (data_width +  textwidth (message)) ÷  2 ), data_width)
295+                                     printstyled (centered_message, " \n " = :light_black )
296+                                 end 
297+                             end 
298+                         end 
265299                        before =  time ()
266300                        resp, duration =  try 
267301                                r =  remotecall_fetch (@Base . world (runtests, ∞), wrkr, test, test_path (test); seed= seed)
@@ -271,6 +305,10 @@ cd(@__DIR__) do
271305                                Any[CapturedException (e, catch_backtrace ())], time () -  before
272306                            end 
273307                        delete! (running_tests, test)
308+                         if  haskey (test_timers, test)
309+                             close (test_timers[test])
310+                             delete! (test_timers, test)
311+                         end 
274312                        push! (results, (test, resp, duration))
275313                        if  length (resp) ==  1 
276314                            print_testworker_errored (test, wrkr, exit_on_error ?  nothing  :  resp[1 ])
@@ -355,6 +393,9 @@ cd(@__DIR__) do
355393        if  @isdefined  stdin_monitor
356394            schedule (stdin_monitor, InterruptException (); error= true )
357395        end 
396+         if  @isdefined  test_timers
397+             foreach (close, values (test_timers))
398+         end 
358399    end 
359400
360401    #= 
0 commit comments