diff options
| -rwxr-xr-x | build-aux/test-driver.scm | 60 |
1 files changed, 33 insertions, 27 deletions
diff --git a/build-aux/test-driver.scm b/build-aux/test-driver.scm index 7c211f51ef9..20bd8f095ed 100755 --- a/build-aux/test-driver.scm +++ b/build-aux/test-driver.scm | |||
| @@ -3,10 +3,11 @@ exec guile --no-auto-compile -e main -s "$0" "$@" | |||
| 3 | !# | 3 | !# |
| 4 | ;;;; test-driver.scm - Guile test driver for Automake testsuite harness | 4 | ;;;; test-driver.scm - Guile test driver for Automake testsuite harness |
| 5 | 5 | ||
| 6 | (define script-version "2026-03-19.13") ;UTC | 6 | (define script-version "2026-03-19.14") ;UTC |
| 7 | 7 | ||
| 8 | ;;; Copyright © 2015, 2016 Mathieu Lirzin <mthl@gnu.org> | 8 | ;;; Copyright © 2015, 2016 Mathieu Lirzin <mthl@gnu.org> |
| 9 | ;;; Copyright © 2021 Maxim Cournoyer <maxim@guixotic.coop> | 9 | ;;; Copyright © 2021 Maxim Cournoyer <maxim@guixotic.coop> |
| 10 | ;;; Copyright © 2024 Tomas Volf <~@wolfsden.cz> | ||
| 10 | ;;; | 11 | ;;; |
| 11 | ;;; This program is free software; you can redistribute it and/or modify it | 12 | ;;; This program is free software; you can redistribute it and/or modify it |
| 12 | ;;; under the terms of the GNU General Public License as published by | 13 | ;;; under the terms of the GNU General Public License as published by |
| @@ -35,7 +36,8 @@ exec guile --no-auto-compile -e main -s "$0" "$@" | |||
| 35 | (srfi srfi-1) | 36 | (srfi srfi-1) |
| 36 | (srfi srfi-19) | 37 | (srfi srfi-19) |
| 37 | (srfi srfi-26) | 38 | (srfi srfi-26) |
| 38 | (srfi srfi-64)) | 39 | (srfi srfi-64) |
| 40 | (srfi srfi-71)) | ||
| 39 | 41 | ||
| 40 | (define (show-help) | 42 | (define (show-help) |
| 41 | (display "Usage: | 43 | (display "Usage: |
| @@ -114,15 +116,18 @@ case is shown.\n")) | |||
| 114 | (out-port (current-output-port)) | 116 | (out-port (current-output-port)) |
| 115 | (trs-port (%make-void-port "w")) | 117 | (trs-port (%make-void-port "w")) |
| 116 | select exclude) | 118 | select exclude) |
| 117 | "Return a custom SRFI-64 test runner. TEST-NAME is a string specifying the | 119 | "Return a custom SRFI-64 test runner and a `finalize' procedure as multiple |
| 118 | file name of the current the test. COLOR? specifies whether to use colors. | 120 | values. TEST-NAME is a string specifying the file name of the current the |
| 119 | When BRIEF? is true, the individual test cases results are masked and only the | 121 | test. COLOR? specifies whether to use colors. When BRIEF? is true, the |
| 120 | summary is shown. ERRORS-ONLY? reduces the amount of test case metadata | 122 | individual test cases results are masked and only the summary is shown. |
| 121 | logged to only that of the failed test cases. OUT-PORT and TRS-PORT must be | 123 | ERRORS-ONLY? reduces the amount of test case metadata logged to only that of |
| 122 | output ports. OUT-PORT defaults to the current output port, while TRS-PORT | 124 | the failed test cases. OUT-PORT and TRS-PORT must be output ports. OUT-PORT |
| 123 | defaults to a void port, which means no TRS output is logged. SELECT and | 125 | defaults to the current output port, while TRS-PORT defaults to a void port, |
| 124 | EXCLUDE may take a regular expression to select or exclude individual test | 126 | which means no TRS output is logged. SELECT and EXCLUDE may take a regular |
| 125 | cases based on their names." | 127 | expression to select or exclude individual test cases based on their names. |
| 128 | |||
| 129 | After the tests are finished running, the `finalize' procedure should be | ||
| 130 | called to do the final reporting." | ||
| 126 | 131 | ||
| 127 | (define test-cases-start-time (make-hash-table)) | 132 | (define test-cases-start-time (make-hash-table)) |
| 128 | 133 | ||
| @@ -180,8 +185,8 @@ cases based on their names." | |||
| 180 | (result->string (test-result-kind* runner)) | 185 | (result->string (test-result-kind* runner)) |
| 181 | (test-runner-test-name runner) time-elapsed-seconds))) | 186 | (test-runner-test-name runner) time-elapsed-seconds))) |
| 182 | 187 | ||
| 183 | (define (test-on-group-end-gnu runner) | 188 | (define (finalize runner) |
| 184 | ;; Procedure called by a 'test-end', including at the end of a test-group. | 189 | "Procedure to call after all tests finish to do the final reporting." |
| 185 | (let ((fail (or (positive? (test-runner-fail-count runner)) | 190 | (let ((fail (or (positive? (test-runner-fail-count runner)) |
| 186 | (positive? (test-runner-xpass-count runner)))) | 191 | (positive? (test-runner-xpass-count runner)))) |
| 187 | (skip (or (positive? (test-runner-skip-count runner)) | 192 | (skip (or (positive? (test-runner-skip-count runner)) |
| @@ -198,15 +203,14 @@ cases based on their names." | |||
| 198 | (format out-port "~A: ~A~%" | 203 | (format out-port "~A: ~A~%" |
| 199 | (result->string (if fail 'fail (if skip 'skip 'pass)) | 204 | (result->string (if fail 'fail (if skip 'skip 'pass)) |
| 200 | #:colorize? color?) | 205 | #:colorize? color?) |
| 201 | test-name)) | 206 | test-name)))) |
| 202 | #f)) | ||
| 203 | 207 | ||
| 204 | (let ((runner (test-runner-null))) | 208 | (let ((runner (test-runner-null))) |
| 205 | (test-runner-on-test-begin! runner test-on-test-begin-gnu) | 209 | (test-runner-on-test-begin! runner test-on-test-begin-gnu) |
| 206 | (test-runner-on-test-end! runner test-on-test-end-gnu) | 210 | (test-runner-on-test-end! runner test-on-test-end-gnu) |
| 207 | (test-runner-on-group-end! runner test-on-group-end-gnu) | ||
| 208 | (test-runner-on-bad-end-name! runner test-on-bad-end-name-simple) | 211 | (test-runner-on-bad-end-name! runner test-on-bad-end-name-simple) |
| 209 | runner)) | 212 | (values runner |
| 213 | (λ () (finalize runner))))) | ||
| 210 | 214 | ||
| 211 | 215 | ||
| 212 | ;;; | 216 | ;;; |
| @@ -252,17 +256,19 @@ cases based on their names." | |||
| 252 | (redirect-port log (current-output-port)) | 256 | (redirect-port log (current-output-port)) |
| 253 | (redirect-port log (current-warning-port)) | 257 | (redirect-port log (current-warning-port)) |
| 254 | (redirect-port log (current-error-port))) | 258 | (redirect-port log (current-error-port))) |
| 255 | (test-with-runner | 259 | (let ((runner |
| 256 | (test-runner-gnu test-name | 260 | finalize (test-runner-gnu |
| 257 | #:color? color-tests | 261 | test-name |
| 258 | #:brief? (option->boolean opts 'brief) | 262 | #:color? color-tests |
| 259 | #:errors-only? (option->boolean opts 'errors-only) | 263 | #:brief? (option->boolean opts 'brief) |
| 260 | #:show-duration? (option->boolean | 264 | #:errors-only? (option->boolean opts 'errors-only) |
| 261 | opts 'show-duration) | 265 | #:show-duration? (option->boolean |
| 262 | #:out-port out #:trs-port trs) | 266 | opts 'show-duration) |
| 263 | (test-apply test-specifier | 267 | #:out-port out #:trs-port trs))) |
| 268 | (test-apply runner test-specifier | ||
| 264 | (lambda _ | 269 | (lambda _ |
| 265 | (load-from-path test-name)))) | 270 | (load-from-path test-name))) |
| 271 | (finalize)) | ||
| 266 | (and=> log close-port) | 272 | (and=> log close-port) |
| 267 | (and=> trs close-port) | 273 | (and=> trs close-port) |
| 268 | (close-port out)))) | 274 | (close-port out)))) |
