skribilo-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] tests: Determine current test runner before test-end is called


From: soeren
Subject: [PATCH] tests: Determine current test runner before test-end is called
Date: Fri, 18 Jun 2021 19:51:15 +0200

From: Sören Tempel <soeren+git@soeren-tempel.net>

According to SRFI 64 test-end will remove the test-runner installed by
the matching test-begin. As such, it seems that test-runner-current will
return #f, if called after test-end. Since all skribilo test cases call
test-runner-current after test-end, the following exception is currently
thrown with Guile 3.0.6:

        Backtrace:
        In ice-9/boot-9.scm:
          1752:10  6 (with-exception-handler _ _ #:unwind? _ # _)
        In unknown file:
                   5 (apply-smob/0 #<thunk 7fe66b7d4ee0>)
        In ice-9/boot-9.scm:
            724:2  4 (call-with-prompt _ _ #<procedure default-prompt-handle…>)
        In ice-9/eval.scm:
            619:8  3 (_ #(#(#<directory (guile-user) 7fe66b7cec80>)))
        In ice-9/boot-9.scm:
           2835:4  2 (save-module-excursion _)
          4380:12  1 (_)
        In 
/home/soeren/src/aports/testing/skribilo/src/skribilo-0.9.5/tests/ast.test:
            116:9  0 (_)

Thereby always causing all tests, as executed by `make test`, to fail. I
am not too familiar with Guile so it is unclear to me how the current
code ever worked. My proposed patch stores the current failure count in
a local variable before invoking test-end, thereby fixing the exception
above.

While at it, I also replaced the test-runner-current procedure with
test-runner-get since the latter throws an exception if the test runner
isn't set (making similar issues easier to debug in the future).
Furthermore, I replaced the comparison with zero with the zero?
predicate for readability.
---
 tests/ast.test          | 7 +++----
 tests/engines/info.test | 7 +++----
 tests/location.test     | 7 +++----
 tests/resolve.test      | 7 +++----
 4 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/tests/ast.test b/tests/ast.test
index 8b8db48..5258eb9 100644
--- a/tests/ast.test
+++ b/tests/ast.test
@@ -110,7 +110,6 @@
     (equal? (map markup-ident lst)
             '("0" "1" "2"))))
 
-(test-end "ast")
-
-
-(exit (= (test-runner-fail-count (test-runner-current)) 0))
+(let ((failures (test-runner-fail-count (test-runner-get))))
+  (test-end "ast")
+  (exit (zero? failures)))
diff --git a/tests/engines/info.test b/tests/engines/info.test
index ea3f17e..72108cd 100644
--- a/tests/engines/info.test
+++ b/tests/engines/info.test
@@ -86,10 +86,9 @@
                 (equal? prev "c")
                 (not next))))))
 
-(test-end "info")
-
-
-(exit (= (test-runner-fail-count (test-runner-current)) 0))
+(let ((failures (test-runner-fail-count (test-runner-get))))
+  (test-end "info")
+  (exit (zero? failures)))
 
 ;; Local Variables:
 ;; coding: utf-8
diff --git a/tests/location.test b/tests/location.test
index ae6c462..f09fe20 100644
--- a/tests/location.test
+++ b/tests/location.test
@@ -86,10 +86,9 @@
         (section :title \"baz\"                   ; 5
           (p [Paragraph.]))))")                   ; 6
 
-(test-end "location")
-
-
-(exit (= (test-runner-fail-count (test-runner-current)) 0))
+(let ((failures (test-runner-fail-count (test-runner-get))))
+  (test-end "location")
+  (exit (zero? failures)))
 
 ;; Local Variables:
 ;; eval: (put 'call-with-code 'scheme-indent-function 1)
diff --git a/tests/resolve.test b/tests/resolve.test
index 1241aab..0f8bcb2 100644
--- a/tests/resolve.test
+++ b/tests/resolve.test
@@ -213,7 +213,6 @@
            (ch*  (document-lookup-node doc "c")))
       (eq? ch ch*))))
 
-(test-end "resolve")
-
-
-(exit (= (test-runner-fail-count (test-runner-current)) 0))
+(let ((failures (test-runner-fail-count (test-runner-get))))
+  (test-end "resolve")
+  (exit (zero? failures)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]