rackunit: prevent test case from killing test-runner thread
closes PR 11586 original commit: a100395626c0e7f569ddc301ac4d57cbc6f4607a
This commit is contained in:
parent
0f5266d34a
commit
3a84f89c4d
|
@ -26,7 +26,8 @@
|
||||||
;; Run a test-case immediately, printing information on failure
|
;; Run a test-case immediately, printing information on failure
|
||||||
(define (default-test-case-around thunk)
|
(define (default-test-case-around thunk)
|
||||||
(with-handlers ([(lambda (e) #t) default-test-case-handler])
|
(with-handlers ([(lambda (e) #t) default-test-case-handler])
|
||||||
(thunk)))
|
(parameterize ((current-custodian (make-custodian)))
|
||||||
|
(thunk))))
|
||||||
|
|
||||||
;; default-test-case-handler : any -> any
|
;; default-test-case-handler : any -> any
|
||||||
(define (default-test-case-handler e)
|
(define (default-test-case-handler e)
|
||||||
|
|
|
@ -216,6 +216,7 @@
|
||||||
|
|
||||||
;; run-tests : test [(U 'quiet 'normal 'verbose)] -> integer
|
;; run-tests : test [(U 'quiet 'normal 'verbose)] -> integer
|
||||||
(define (run-tests test [mode 'normal])
|
(define (run-tests test [mode 'normal])
|
||||||
|
(parameterize ((current-custodian (make-custodian)))
|
||||||
(monad-value
|
(monad-value
|
||||||
((compose
|
((compose
|
||||||
(sequence*
|
(sequence*
|
||||||
|
@ -239,4 +240,4 @@
|
||||||
((normal) (std-test/text-ui display-context test))
|
((normal) (std-test/text-ui display-context test))
|
||||||
((verbose) (std-test/text-ui
|
((verbose) (std-test/text-ui
|
||||||
(lambda (x) (display-context x #t))
|
(lambda (x) (display-context x #t))
|
||||||
test))))))
|
test)))))))
|
||||||
|
|
|
@ -220,5 +220,19 @@
|
||||||
(check = foo 2)))
|
(check = foo 2)))
|
||||||
'verbose)
|
'verbose)
|
||||||
(check = foo 3)))))
|
(check = foo 3)))))
|
||||||
))
|
|
||||||
|
|
||||||
|
(test-case
|
||||||
|
"cannot kill current thread in test case"
|
||||||
|
(check-equal? (call-in-nested-thread
|
||||||
|
(lambda ()
|
||||||
|
(with-silent-output
|
||||||
|
(lambda ()
|
||||||
|
(run-tests
|
||||||
|
(test-suite "tests"
|
||||||
|
(test-case "kill-thread"
|
||||||
|
(kill-thread (current-thread)))))))))
|
||||||
|
;; If the kill-thread were successful, call-in-nested-thread
|
||||||
|
;; would raise error. We expect kill-thread to raise error,
|
||||||
|
;; caught by run-tests.
|
||||||
|
1))
|
||||||
|
))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user