guile-knots/tests.scm
Christopher Baines ab5411da42
All checks were successful
/ test (push) Successful in 9s
Make resource pool changes and add parallelism limiter
This was motivated by trying to allow for completely cleaning up
resource pools, which involved removing their use of fiberize which
currently has no destroy mechanism.

As part of this, there's a new parallelism limiter mechanism using
resource pools rather than fibers, and also a fixed size resource
pool.

The tests now drain? and destroy the resource pools to check cleaning
up.
2025-06-26 10:43:46 +02:00

31 lines
863 B
Scheme

(define-module (tests)
#:use-module (ice-9 exceptions)
#:use-module (fibers)
#:export (run-fibers-for-tests
assert-no-heap-growth))
(define* (run-fibers-for-tests thunk #:key (drain? #t))
(let ((result
(run-fibers
(lambda ()
(with-exception-handler
(lambda (exn)
exn)
(lambda ()
(simple-format #t "running ~A\n" thunk)
(with-exception-handler
(lambda (exn)
(backtrace)
(raise-exception exn))
thunk)
#t)
#:unwind? #t))
#:hz 0
#:parallelism 1
#:drain? drain?)))
(if (exception? result)
(raise-exception result)
result)))
(define (assert-no-heap-growth thunk)
(thunk))