aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2023-12-07 09:58:14 +0100
committerWojtek Kosior <koszko@koszko.org>2023-12-12 19:18:26 +0100
commitdae06b96848965f7d1b7e2f954d2f8faea50d9cc (patch)
tree0f30216cb806d32ee28df0224a91f1bbf233b9b3 /src
parentd307e7dd8ce4d16657f49a4d5e0629212e568386 (diff)
downloadmyra-test-utils-apprentice.tar.gz
myra-test-utils-apprentice.zip
Make `--test-name` optional and start using `TEST-SCRIPT` argument.HEADapprentice
* src/guile/myra-test-utils/driver.scm (define-module): Import `match:substring`. (show-help): Display `--test-name` as a non-mandatory option. (run-test-driver): Use the first non-option argument as the script name to load. Make test name default to the script name. Allow loading compiled version of the test script.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/guile/myra-test-utils/driver.scm16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/guile/myra-test-utils/driver.scm b/src/guile/myra-test-utils/driver.scm
index 0369fe1..8331463 100755
--- a/src/guile/myra-test-utils/driver.scm
+++ b/src/guile/myra-test-utils/driver.scm
@@ -30,7 +30,7 @@
#:use-module ((ice-9 format) #:select (format))
#:use-module ((ice-9 getopt-long) #:select (getopt-long option-ref))
#:use-module ((ice-9 pretty-print) #:select (pretty-print))
- #:use-module ((ice-9 regex) #:select (string-match))
+ #:use-module ((ice-9 regex) #:select (string-match match:substring))
#:use-module ((srfi srfi-1) #:select (filter-map))
#:use-module ((srfi srfi-19) #:prefix s19:)
#:use-module ((srfi srfi-26) #:select (cut))
@@ -42,7 +42,7 @@
(define (show-help)
(display "Usage:
- test-driver --test-name=NAME [--log-file=PATH] [--trs-file=PATH]
+ test-driver [--test-name=NAME] [--log-file=PATH] [--trs-file=PATH]
[--expect-failure={yes|no}] [--color-tests={yes|no}]
[--select=REGEXP] [--exclude=REGEXP] [--errors-only={yes|no}]
[--enable-hard-errors={yes|no}] [--brief={yes|no}}]
@@ -247,7 +247,11 @@ cases based on their names."
(let* ((log (and=> (option 'log-file #f) (cut open-file <> "w0")))
(trs (and=> (option 'trs-file #f) (cut open-file <> "wl")))
(out (duplicate-port (current-output-port) "wl"))
- (test-name (option 'test-name #f))
+ (test-filename (car (option '() #f)))
+ (match-vec (string-match "([^/]*)\\.(scm|go)$" test-filename))
+ (test-filename-base (match:substring match-vec 1))
+ (test-dir (canonicalize-path (dirname test-filename)))
+ (test-name (option 'test-name test-filename))
(select (option 'select #f))
(exclude (option 'exclude #f))
(test-specifiers (filter-map
@@ -284,7 +288,11 @@ convenient interactive line editing and input history.\n\n"
#:out-port out #:trs-port trs)
(s64:test-apply test-specifier
(lambda _
- (load-from-path test-name)))))
+ (set! %load-path
+ (cons test-dir %load-path))
+ (set! %load-compiled-path
+ (cons test-dir %load-compiled-path))
+ (load-from-path test-filename-base)))))
(and=> log close-port)
(and=> trs close-port)
(close-port out))))