@@ -15,6 +15,9 @@ include("buildkitetestjson.jl")
1515
1616using . BuildkiteTestJSON
1717
18+ const longrunning_delay = parse (Int, get (ENV , " JULIA_TEST_LONGRUNNING_DELAY" , " 45" )) * 60 # minutes
19+ const longrunning_interval = parse (Int, get (ENV , " JULIA_TEST_LONGRUNNING_INTERVAL" , " 15" )) * 60 # minutes
20+
1821(; tests, net_on, exit_on_error, use_revise, seed) = choosetests (ARGS )
1922tests = unique (tests)
2023
@@ -175,10 +178,10 @@ cd(@__DIR__) do
175178 at = lpad (" ($wrkr )" , name_align - textwidth (name) + 1 , " " )
176179 lock (print_lock)
177180 try
178- printstyled (name, at, " |" , " " ^ elapsed_align,
179- " started at $(now ()) " ,
181+ printstyled (name, at, " |" , " " ^ elapsed_align, color = :white )
182+ printstyled ( " started at $(now ()) " ,
180183 (pid > 0 ? " on pid $pid " : " " ),
181- " \n " , color= :white )
184+ " \n " , color= :light_black )
182185 finally
183186 unlock (print_lock)
184187 end
@@ -215,6 +218,10 @@ cd(@__DIR__) do
215218 # Monitor stdin and kill this task on ^C
216219 # but don't do this on Windows, because it may deadlock in the kernel
217220 running_tests = Dict {String, DateTime} ()
221+
222+ # Track timeout timers for each test
223+ test_timers = Dict {String, Timer} ()
224+
218225 if ! Sys. iswindows () && isa (stdin , Base. TTY)
219226 t = current_task ()
220227 stdin_monitor = @async begin
@@ -249,6 +256,33 @@ cd(@__DIR__) do
249256 test = popfirst! (tests)
250257 running_tests[test] = now ()
251258 wrkr = p
259+
260+ # Create a timer for this test to report long-running status
261+ test_timers[test] = Timer (longrunning_delay, interval= longrunning_interval) do timer
262+ if haskey (running_tests, test) # Check test is still running
263+ start_time = running_tests[test]
264+ elapsed = now () - start_time
265+ elapsed_minutes = elapsed. value ÷ (1000 * 60 )
266+
267+ elapsed_str = if elapsed_minutes >= 60
268+ hours, mins = divrem (elapsed_minutes, 60 )
269+ " $(hours) h $(mins) m"
270+ else
271+ " $(elapsed_minutes) m"
272+ end
273+
274+ @lock print_lock begin
275+ print (test)
276+ print (lpad (" ($(wrkr) )" , name_align - textwidth (test) + 1 , " " ), " | " )
277+ # Calculate total width of data columns: "Time (s) | GC (s) | GC % | Alloc (MB) | RSS (MB)"
278+ # This is: elapsed_align + 3 + gc_align + 3 + percent_align + 3 + alloc_align + 3 + rss_align
279+ data_width = elapsed_align + gc_align + percent_align + alloc_align + rss_align + 12 # 12 = 4 * " | "
280+ message = " has been running for $(elapsed_str) "
281+ centered_message = lpad (rpad (message, (data_width + textwidth (message)) ÷ 2 ), data_width)
282+ printstyled (centered_message, " \n " , color= :light_black )
283+ end
284+ end
285+ end
252286 before = time ()
253287 resp, duration = try
254288 r = remotecall_fetch (@Base . world (runtests, ∞), wrkr, test, test_path (test); seed= seed)
@@ -258,6 +292,10 @@ cd(@__DIR__) do
258292 Any[CapturedException (e, catch_backtrace ())], time () - before
259293 end
260294 delete! (running_tests, test)
295+ if haskey (test_timers, test)
296+ close (test_timers[test])
297+ delete! (test_timers, test)
298+ end
261299 push! (results, (test, resp, duration))
262300 if length (resp) == 1
263301 print_testworker_errored (test, wrkr, exit_on_error ? nothing : resp[1 ])
@@ -342,6 +380,9 @@ cd(@__DIR__) do
342380 if @isdefined stdin_monitor
343381 schedule (stdin_monitor, InterruptException (); error= true )
344382 end
383+ if @isdefined test_timers
384+ foreach (close, values (test_timers))
385+ end
345386 end
346387
347388 #=
0 commit comments