summaryrefslogtreecommitdiff
path: root/build-aux
diff options
context:
space:
mode:
authorTomas Volf <~@wolfsden.cz>2024-07-15 22:53:02 +0200
committerMaxim Cournoyer <maxim@guixotic.coop>2026-03-20 17:38:15 +0900
commit18ea608fcfec49a8a2f298714f745db9a9cbfc8b (patch)
treee2cd9dc489df7ee788f68e3d43d6120b6b410352 /build-aux
parentef4ba3191f013a92e400b24e3e02deb99da3a618 (diff)
build: test-driver.scm: Utilize test-runner-group-path.
Test groups were not used in any meaningful way. The group path was not printed and it was not used in test selection mechanism. I think groups are useful, and it is nice to be able to, for example, run tests from a single group. This commit does two things. First, it changes the test reporting to include the value returned from test-runner-group-path, so you will know not only the test name, but the test group(s) as well. And second, it changes the test selection (and exclusion) process to match against the "full" test name, so group path + test name. Hence (test-begin "failing tests") (test-equal "this should fail" 1 2) (test-end) will, depending on the output location, produce following text. .trs: :test-result: FAIL failing tests: this should fail [0.000s] :test-global-result: FAIL :recheck: yes :copy-in-global-log: yes .log: test-name: failing tests: this should fail location: test.scm:140 source: + (test-equal "this should fail" 1 2) expected-value: 1 actual-value: 2 result: FAIL stdout: FAIL: test.scm - failing tests: this should fail [0.000s] * build-aux/test-driver.scm (current-test-full-name): New procedure. (test-runner-gnu): Use current-test-full-name instead of test-runner-test-name. (test-match-name*): Match against current-test-full-name. Use compose. (test-match-name*/negated): Rewrite in terms of test-match-name*. Change-Id: I3fb9a2a721165204f020b79e019533f799b790e4 Signed-off-by: Maxim Cournoyer <maxim@guixotic.coop> Modified-by: Maxim Cournoyer <maxim@guixotic.coop>
Diffstat (limited to 'build-aux')
-rwxr-xr-xbuild-aux/test-driver.scm20
1 files changed, 12 insertions, 8 deletions
diff --git a/build-aux/test-driver.scm b/build-aux/test-driver.scm
index 6eb3a863f6a..b74f8a23c71 100755
--- a/build-aux/test-driver.scm
+++ b/build-aux/test-driver.scm
@@ -106,6 +106,12 @@ case is shown.\n"))
106 (or (test-result-ref runner 'result-kind) 106 (or (test-result-ref runner 'result-kind)
107 'skip)) 107 'skip))
108 108
109(define (current-test-full-name runner)
110 "Get full name (test group path + name) of current test."
111 (format #f "~{~a~^/~}: ~a"
112 (test-runner-group-path runner)
113 (test-runner-test-name runner)))
114
109 115
110;;; 116;;;
111;;; SRFI 64 custom test runner. 117;;; SRFI 64 custom test runner.
@@ -134,7 +140,7 @@ called to do the final reporting."
134 (define (test-on-test-begin-gnu runner) 140 (define (test-on-test-begin-gnu runner)
135 ;; Procedure called at the start of an individual test case, before the 141 ;; Procedure called at the start of an individual test case, before the
136 ;; test expression (and expected value) are evaluated. 142 ;; test expression (and expected value) are evaluated.
137 (let ((test-case-name (test-runner-test-name runner)) 143 (let ((test-case-name (current-test-full-name runner))
138 (start-time (current-time time-monotonic))) 144 (start-time (current-time time-monotonic)))
139 (hash-set! test-cases-start-time test-case-name start-time))) 145 (hash-set! test-cases-start-time test-case-name start-time)))
140 146
@@ -151,7 +157,7 @@ called to do the final reporting."
151 (let* ((results (test-result-alist runner)) 157 (let* ((results (test-result-alist runner))
152 (result? (cut assq <> results)) 158 (result? (cut assq <> results))
153 (result (cut assq-ref results <>)) 159 (result (cut assq-ref results <>))
154 (test-case-name (test-runner-test-name runner)) 160 (test-case-name (current-test-full-name runner))
155 (start (hash-ref test-cases-start-time test-case-name)) 161 (start (hash-ref test-cases-start-time test-case-name))
156 (end (current-time time-monotonic)) 162 (end (current-time time-monotonic))
157 (time-elapsed (time-difference end start)) 163 (time-elapsed (time-difference end start))
@@ -165,7 +171,7 @@ called to do the final reporting."
165 (and show-duration? time-elapsed-seconds))) 171 (and show-duration? time-elapsed-seconds)))
166 172
167 (unless (and errors-only? (not (test-failed? runner))) 173 (unless (and errors-only? (not (test-failed? runner)))
168 (format #t "test-name: ~A~%" (test-runner-test-name runner)) 174 (format #t "test-name: ~A~%" test-case-name)
169 (format #t "location: ~A~%" 175 (format #t "location: ~A~%"
170 (string-append (result 'source-file) ":" 176 (string-append (result 'source-file) ":"
171 (number->string (result 'source-line)))) 177 (number->string (result 'source-line))))
@@ -183,7 +189,7 @@ called to do the final reporting."
183 189
184 (format trs-port ":test-result: ~A ~A [~,3fs]~%" 190 (format trs-port ":test-result: ~A ~A [~,3fs]~%"
185 (result->string (test-result-kind* runner)) 191 (result->string (test-result-kind* runner))
186 (test-runner-test-name runner) time-elapsed-seconds))) 192 test-case-name time-elapsed-seconds)))
187 193
188 (define (finalize runner) 194 (define (finalize runner)
189 "Procedure to call after all tests finish to do the final reporting." 195 "Procedure to call after all tests finish to do the final reporting."
@@ -229,13 +235,11 @@ called to do the final reporting."
229;;; 235;;;
230(define (test-match-name* regexp) 236(define (test-match-name* regexp)
231 "Return a test specifier that matches a test name against REGEXP." 237 "Return a test specifier that matches a test name against REGEXP."
232 (lambda (runner) 238 (compose (cut string-match regexp <>) current-test-full-name))
233 (string-match regexp (test-runner-test-name runner))))
234 239
235(define (test-match-name*/negated regexp) 240(define (test-match-name*/negated regexp)
236 "Return a negated test specifier version of test-match-name*." 241 "Return a negated test specifier version of test-match-name*."
237 (lambda (runner) 242 (compose not (test-match-name* regexp)))
238 (not (string-match regexp (test-runner-test-name runner)))))
239 243
240 244
241;;; 245;;;