From d307e7dd8ce4d16657f49a4d5e0629212e568386 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Thu, 7 Dec 2023 09:33:52 +0100 Subject: Make "by-hand" execution of test-driver easier. * src/guile/myra-test-utils/driver.scm (define-module): Import `%interactive-debugging`. (show-help): Display `--log-file` and `--trs-file` as non-mandatory options. (run-test-driver): For invokations without log file set cause REPL to be spawned on test expressions that errored-out. Configure readline support for the REPL if available. --- src/guile/myra-test-utils/driver.scm | 41 ++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 14 deletions(-) (limited to 'src/guile') diff --git a/src/guile/myra-test-utils/driver.scm b/src/guile/myra-test-utils/driver.scm index bfb5a1f..0369fe1 100755 --- a/src/guile/myra-test-utils/driver.scm +++ b/src/guile/myra-test-utils/driver.scm @@ -35,13 +35,14 @@ #:use-module ((srfi srfi-19) #:prefix s19:) #:use-module ((srfi srfi-26) #:select (cut)) #:use-module ((srfi srfi-64) #:prefix s64:) + #:use-module ((myra-test-utils) #:select (%interactive-debugging)) #:export (run-test-driver)) -(define script-version "2023-12-06.16") ;UTC +(define script-version "2023-12-07.08") ;UTC (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}}] @@ -257,21 +258,33 @@ cases based on their names." (color-tests (if (assoc 'color-tests opts) (option->boolean opts 'color-tests) #t))) - (when log + (cond + (log (redirect-port log (current-output-port)) (redirect-port log (current-warning-port)) (redirect-port log (current-error-port))) - (s64:test-with-runner - (test-runner-gnu test-name - #:color? color-tests - #:brief? (option->boolean opts 'brief) - #:errors-only? (option->boolean opts 'errors-only) - #:show-duration? (option->boolean - opts 'show-duration) - #:out-port out #:trs-port trs) - (s64:test-apply test-specifier - (lambda _ - (load-from-path test-name)))) + ((false-if-exception (resolve-interface '(ice-9 readline))) + => + (lambda (module) + ;; Enable completion and input history at the REPL. + ((module-ref module 'activate-readline)))) + (else + (display "Consider installing the 'guile-readline' package for +convenient interactive line editing and input history.\n\n" + out))) + (parameterize ((%interactive-debugging (not log))) + (s64:test-with-runner + (test-runner-gnu test-name + #:color? color-tests + #:brief? (option->boolean opts 'brief) + #:errors-only? (option->boolean + opts 'errors-only) + #:show-duration? (option->boolean + opts 'show-duration) + #:out-port out #:trs-port trs) + (s64:test-apply test-specifier + (lambda _ + (load-from-path test-name))))) (and=> log close-port) (and=> trs close-port) (close-port out)))) -- cgit v1.2.3