1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

[srfi-64] Fix a bug with test-end removing globally installed test-runner

* testing.scm (%test-begin, %test-end): When (test-runner-current) is
not set, create a new one like before but also add a finalizer that
will remove it after the test is finished. Previously the test runner
was getting unset unconditionally.

See https://srfi-email.schemers.org/srfi-64/msg/16468240/
This commit is contained in:
jakub-w 2021-04-22 15:13:55 +02:00 committed by Daniel Llorens
parent 5969490f55
commit f10bc1a864

View file

@ -278,7 +278,11 @@
(define (%test-begin suite-name count)
(if (not (test-runner-current))
(test-runner-current (test-runner-create)))
(let ((r (test-runner-create)))
(test-runner-current r)
(test-runner-on-final! r
(let ((old-final (test-runner-on-final r)))
(lambda (r) (old-final r) (test-runner-current #f))))))
(let ((runner (test-runner-current)))
((test-runner-on-group-begin runner) runner suite-name count)
(%test-runner-skip-save! runner
@ -433,9 +437,8 @@
(%test-runner-fail-list! r (car (%test-runner-fail-save r)))
(%test-runner-fail-save! r (cdr (%test-runner-fail-save r)))
(%test-runner-count-list! r (cdr count-list))
(cond ((null? (test-runner-group-stack r))
((test-runner-on-final r) r)
(test-runner-current #f))))))
(if (null? (test-runner-group-stack r))
((test-runner-on-final r) r)))))
(define-syntax test-group
(syntax-rules ()