raco test: add --heartbeat flag

Useful when running many tests in parallel to keep track of a test
that is running especially long (and maybe stuck).

original commit: f3c8638366
This commit is contained in:
Matthew Flatt 2014-06-16 15:23:42 +01:00
parent 52ac9d616e
commit 60fe855cf7

View File

@ -31,6 +31,7 @@
(define table? #f) (define table? #f)
(define fresh-user? #f) (define fresh-user? #f)
(define empty-input? #f) (define empty-input? #f)
(define heartbeat-secs #f)
(define ignore-stderr-patterns null) (define ignore-stderr-patterns null)
(define jobs 0) ; 0 mean "default" (define jobs 0) ; 0 mean "default"
@ -490,6 +491,24 @@
(format " ~s" (format "~a" a))))) (format " ~s" (format "~a" a)))))
(flush-output)) (flush-output))
id))) id)))
(define heartbeat-sema (make-semaphore))
(define heartbeat-t
(and heartbeat-secs
(thread (lambda ()
(let loop ()
(unless (sync/timeout heartbeat-secs heartbeat-sema)
(call-with-semaphore
ids-lock
(lambda ()
(printf "raco test: ~a[still on ~s]\n"
(if (jobs . <= . 1)
""
(format "~a " id))
(let ([m (normalize-module-path p)])
(if (and (pair? mod) (eq? 'submod (car mod)))
(list* 'submod m (cddr mod))
m)))))
(loop)))))))
(begin0 (begin0
(dynamic-require* mod 0 (dynamic-require* mod 0
#:id (if (jobs . <= . 1) #:id (if (jobs . <= . 1)
@ -501,6 +520,9 @@
#:responsible responsible #:responsible responsible
#:lock-name lock-name #:lock-name lock-name
#:random? random?) #:random? random?)
(when heartbeat-t
(semaphore-post heartbeat-sema)
(sync heartbeat-t))
(call-with-semaphore (call-with-semaphore
ids-lock ids-lock
(lambda () (lambda ()
@ -972,6 +994,9 @@
[("--quiet" "-q") [("--quiet" "-q")
"Suppress `raco test: ...' message" "Suppress `raco test: ...' message"
(set! quiet? #t)] (set! quiet? #t)]
[("--heartbeat")
"Periodically report that a test is still running"
(set! heartbeat-secs 5)]
[("--table" "-t") [("--table" "-t")
"Print a summary table" "Print a summary table"
(set! table? #t)] (set! table? #t)]