aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorArun Isaac2022-01-23 01:19:40 +0530
committerArun Isaac2022-01-23 13:24:27 +0530
commitc2372d28106af81f9a54bdfd995e784bca9042df (patch)
tree6d730dcd24a300a436c44106a95c9c7fd375ad94 /bin
downloadrun64-c2372d28106af81f9a54bdfd995e784bca9042df.tar.gz
run64-c2372d28106af81f9a54bdfd995e784bca9042df.tar.lz
run64-c2372d28106af81f9a54bdfd995e784bca9042df.zip
Initial commit
Diffstat (limited to 'bin')
-rwxr-xr-xbin/guile-run6421
-rwxr-xr-xbin/run64100
2 files changed, 121 insertions, 0 deletions
diff --git a/bin/guile-run64 b/bin/guile-run64
new file mode 100755
index 0000000..7408db0
--- /dev/null
+++ b/bin/guile-run64
@@ -0,0 +1,21 @@
+#! /bin/sh
+
+# run64 --- SRFI-64 test runner
+# Copyright © 2022 Arun Isaac <arunisaac@systemreboot.net>
+#
+# This file is part of run64.
+#
+# run64 is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# run64 is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+# License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with run64. If not, see <https://www.gnu.org/licenses/>.
+
+guile --no-auto-compile $(which run64) "$@"
diff --git a/bin/run64 b/bin/run64
new file mode 100755
index 0000000..b9fce65
--- /dev/null
+++ b/bin/run64
@@ -0,0 +1,100 @@
+#!r6rs
+;;; -*- mode: scheme -*-
+;;; run64 --- SRFI-64 test runner
+;;; Copyright © 2022 Arun Isaac <arunisaac@systemreboot.net>
+;;;
+;;; This file is part of run64.
+;;;
+;;; run64 is free software: you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation, either version 3 of the License, or
+;;; (at your option) any later version.
+;;;
+;;; run64 is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with run64. If not, see <https://www.gnu.org/licenses/>.
+
+(import (rnrs programs)
+ (srfi srfi-64))
+
+(define (color code str)
+ (string-append (string #\esc)
+ "["
+ (number->string code)
+ "m"
+ str
+ (string #\esc)
+ "[0m"))
+
+(define (red str)
+ (color 31 str))
+
+(define (green str)
+ (color 32 str))
+
+(define (magenta str)
+ (color 35 str))
+
+(define (make-runner)
+ (let ((runner (test-runner-null)))
+ (test-runner-on-group-begin! runner
+ (lambda (runner suite-name count)
+ (display (magenta (string-append "%%%% " suite-name)))
+ (newline)))
+ (test-runner-on-group-end! runner
+ (lambda _
+ (newline)))
+ (test-runner-on-test-end! runner
+ (lambda (runner)
+ (let ((name (test-runner-test-name runner))
+ (result (string-upcase
+ (symbol->string (test-result-kind runner))))
+ (result-alist (test-result-alist runner)))
+ (display (case (test-result-kind runner)
+ ((pass) (green result))
+ (else (red result))))
+ (display " ")
+ (display name)
+ (newline)
+ ;; If test did not pass, print details.
+ (unless (eq? (test-result-kind runner)
+ 'pass)
+ (display (assq-ref result-alist 'source-file))
+ (display (assq-ref result-alist 'source-line))
+ (newline)
+ (display "expected: ")
+ (display (assq-ref result-alist 'expected-value))
+ (newline)
+ (display "actual: ")
+ (display (assq-ref result-alist 'actual-value))
+ (newline)))))
+ runner))
+
+(define (main args)
+ (let ((runner (make-runner)))
+ (test-with-runner runner
+ (for-each load (cdr args))
+ (display (magenta "SUMMARY"))
+ (newline)
+ (display "PASS: ")
+ (display (test-runner-pass-count runner))
+ (newline)
+ (display "FAIL: ")
+ (display (test-runner-fail-count runner))
+ (newline)
+ (display "XPASS: ")
+ (display (test-runner-xpass-count runner))
+ (newline)
+ (display "XFAIL: ")
+ (display (test-runner-xfail-count runner))
+ (newline)
+ (display "SKIP: ")
+ (display (test-runner-skip-count runner))
+ (newline)
+ (exit (zero? (test-runner-fail-count runner))))))
+
+(main (command-line))