1515
1616(defpackage #:ace.test.runner
1717 (:use # :common-lisp # :ace.core)
18- (:import-from # :ace.core.thread
19- # :join-thread
20- # :make-thread
21- # :with-timeout
22- # :make-mutex
23- # :with-mutex)
2418 (:import-from # :ace.core.tty
2519 # :ttyp
2620 # :*print-ansi* )
3529 # :missed
3630 # :*on-missed-expectation*
3731 # :alternate-truth-form)
32+ (:import-from #+ sbcl # :sb-ext #- sbcl # :bordeaux-threads # :timeout)
3833 (:export
3934 ; ; Execution of tests.
4035 # :*checks-count*
4742 # :run-and-report-tests
4843 # :deregister-tests
4944 # :*debug-unit-tests*
50- # :timeout
45+ ; ; TIMEOUT is a symbol naming a condition, and it was confusing to also have it name a function,
46+ ; ; so the function is now named DEFAULT-TIMEOUT
47+ # :default-timeout
5148 # :order))
5249
5350(in-package # :ace.test.runner)
5451
52+ ; ;; Compatibility shims
53+ #+ sbcl
54+ (progn
55+ (eval-when (:compile-toplevel :load-toplevel :execute )
56+ (import ' (sb-thread :make-thread sb-thread :join-thread sb-thread :with-mutex)))
57+ (defmacro with-timeout ((time ) &body body) ` (sb-ext :with-timeout , time ,@ body))
58+ (defun make-mutex (name) (sb-thread :make-mutex :name name)))
59+ #- sbcl
60+ (progn
61+ (eval-when (:compile-toplevel :load-toplevel :execute )
62+ (import ' (bordeaux-threads :make-thread bordeaux-threads :join-thread)))
63+ (defun make-mutex (name) (bordeaux-threads :make-lock name))
64+ (defmacro with-mutex ((lock) &body body) ` (bordeaux-threads :with-lock-held (, lock) ,@ body))
65+ (defmacro with-timeout (&whole form) ` (bordeaux-threads :with-timeout ,@ (cdr form))))
66+
5567; ;; Test execution.
5668
5769(declaim (list *unit-tests* ))
@@ -326,7 +338,7 @@ Returns true if there was no error."
326338 (test-run-start-time run)
327339 (handler-bind ((missed #' on-warning)
328340 (error #' on-error)
329- (bordeaux-threads : timeout #' on-error))
341+ (timeout #' on-error))
330342 (loop do
331343 (with-simple-restart (retry " Retry ~S " test)
332344 (return
@@ -336,7 +348,7 @@ Returns true if there was no error."
336348 (funcall (symbol-function test)))))))
337349 (update-test-run run)))))
338350
339- (defun timeout ()
351+ (defun default- timeout ()
340352 " Return a value for the default test timeout in seconds."
341353 ; ; The test timeout is provided by blaze test in the TEST_TIMEOUT variable.
342354 ; ; See: http://bazel.build/docs/test-encyclopedia.html
@@ -450,7 +462,7 @@ If PARALLEL is NIL, the PARALLEL tests will be empty."))
450462 (let* ((run (make-test-run
451463 :test test
452464 :parallel (and parallel (not (get test ' order)))
453- :timeout (get test ' timeout (timeout))
465+ :timeout (get test ' timeout (default- timeout))
454466 :output-stream (make-string-output-stream )))
455467 (package (symbol-package test))
456468 (name (format nil " ~@[ ~A ::~] ~A "
@@ -563,6 +575,9 @@ If PARALLEL is NIL, the PARALLEL tests will be empty."))
563575 (prog1
564576 (report-tests (%run-tests :debug nil :verbose verbose :out out) :out out)
565577 ; ; Cleanup Lisp-gc managed c-objects so asan doesn't complain
578+ ; ; This GC call assumes that cleanups are synchronous with completion of GC,
579+ ; ; but we've seen ASAN complains anyway as it requires lots of other help.
580+ ; ; So probably just remove this after further testing.
566581 (trivial-garbage :gc :full t )))
567582
568583(defun deregister-tests (&optional (select :all ))
0 commit comments