aboutsummaryrefslogtreecommitdiff
path: root/build-aux
diff options
context:
space:
mode:
authorArun Isaac2021-07-19 15:11:19 +0530
committerArun Isaac2021-07-19 15:11:19 +0530
commit13b77b09e28a92f4f8dc96d6ca54221472eac848 (patch)
treeca174f3872fe053bd54b712a3e46b93fde67591b /build-aux
parentc90eb25e9c5d4143801f72827109c1e6919e5d32 (diff)
downloadccwl-13b77b09e28a92f4f8dc96d6ca54221472eac848.tar.gz
ccwl-13b77b09e28a92f4f8dc96d6ca54221472eac848.tar.lz
ccwl-13b77b09e28a92f4f8dc96d6ca54221472eac848.zip
build-aux: Abstract out colored text.
* build-aux/test-driver.scm.in (color, red, green): New functions. (my-gnu-runner): Call red and green instead of stuffing escape codes into the format string.
Diffstat (limited to 'build-aux')
-rw-r--r--build-aux/test-driver.scm.in14
1 files changed, 11 insertions, 3 deletions
diff --git a/build-aux/test-driver.scm.in b/build-aux/test-driver.scm.in
index 9263707..2ee784c 100644
--- a/build-aux/test-driver.scm.in
+++ b/build-aux/test-driver.scm.in
@@ -40,6 +40,12 @@
(expect-failure (value #t))
(enable-hard-errors (value #t))))
+(define (color code str)
+ (format #f "~a[~am~a~a[0m" #\esc code str #\esc))
+
+(define red (cut color 31 <>))
+(define green (cut color 32 <>))
+
(define (my-gnu-runner log-port trs-port)
(let ((runner (test-runner-null)))
(test-runner-on-group-begin! runner
@@ -55,9 +61,11 @@
(symbol->string (test-result-kind runner))))
(result-alist (test-result-alist runner)))
(format trs-port ":test-result: ~a ~a~%" result name)
- (format #t "\x1b[~:[31~;32~]m~a\x1b[0m ~a~%"
- (eq? (test-result-kind runner) 'pass)
- result name)
+ (format #t "~a ~a~%"
+ (case (test-result-kind runner)
+ ((pass) (green result))
+ (else (red result)))
+ name)
(format log-port "~a ~a~%" result name)
;; If test did not pass, print details.
(unless (eq? (test-result-kind runner) 'pass)