mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
build: test-driver.scm: Add a new '--errors-only' option.
* build-aux/test-driver.scm (show-help): Add the help text for the new '--errors-only' option. (%options): Add the errors-only option. (test-runner-gnu): Add the errors-only? parameter and update doc. Move the logging of the test data after the test has completed, so a choice can be made whether to keep it or discard it based on the value of the test result. (main): Pass the errors-only? option to the driver. * doc/guix.texi (Running the Test Suite): Document the new option.
This commit is contained in:
parent
a1ea2acb37
commit
93a628c4e4
2 changed files with 54 additions and 31 deletions
|
@ -36,12 +36,15 @@ (define (show-help)
|
||||||
(display "Usage:
|
(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}]
|
[--expect-failure={yes|no}] [--color-tests={yes|no}]
|
||||||
[--select=REGEXP] [--exclude=REGEXP]
|
[--select=REGEXP] [--exclude=REGEXP] [--errors-only={yes|no}]
|
||||||
[--enable-hard-errors={yes|no}] [--brief={yes|no}}] [--]
|
[--enable-hard-errors={yes|no}] [--brief={yes|no}}] [--]
|
||||||
TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS]
|
TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS]
|
||||||
The '--test-name' option is mandatory. The '--select' and '--exclude' options
|
The '--test-name' option is mandatory. The '--select' and '--exclude' options
|
||||||
allow selecting or excluding individual test cases via a regexp,
|
allow selecting or excluding individual test cases via a regexp, respectively.
|
||||||
respectively.\n"))
|
The '--errors-only' option can be set to \"yes\" to limit the logged test case
|
||||||
|
metadata to only those test cases that failed. When set to \"yes\", the
|
||||||
|
'--brief' option disables printing the individual test case result to the
|
||||||
|
console.\n"))
|
||||||
|
|
||||||
(define %options
|
(define %options
|
||||||
'((test-name (value #t))
|
'((test-name (value #t))
|
||||||
|
@ -49,6 +52,7 @@ (define %options
|
||||||
(trs-file (value #t))
|
(trs-file (value #t))
|
||||||
(select (value #t))
|
(select (value #t))
|
||||||
(exclude (value #t))
|
(exclude (value #t))
|
||||||
|
(errors-only (value #t))
|
||||||
(color-tests (value #t))
|
(color-tests (value #t))
|
||||||
(expect-failure (value #t)) ;XXX: not implemented yet
|
(expect-failure (value #t)) ;XXX: not implemented yet
|
||||||
(enable-hard-errors (value #t)) ;not implemented in SRFI-64
|
(enable-hard-errors (value #t)) ;not implemented in SRFI-64
|
||||||
|
@ -88,27 +92,26 @@ (define* (result->string symbol #:key colorize?)
|
||||||
;;; SRFI 64 custom test runner.
|
;;; SRFI 64 custom test runner.
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
(define* (test-runner-gnu test-name #:key color? brief?
|
(define* (test-runner-gnu test-name #:key color? brief? errors-only?
|
||||||
(out-port (current-output-port))
|
(out-port (current-output-port))
|
||||||
(trs-port (%make-void-port "w"))
|
(trs-port (%make-void-port "w"))
|
||||||
select exclude)
|
select exclude)
|
||||||
"Return an custom SRFI-64 test runner. TEST-NAME is a string specifying the
|
"Return an custom SRFI-64 test runner. TEST-NAME is a string specifying the
|
||||||
file name of the current the test. COLOR? specifies whether to use colors,
|
file name of the current the test. COLOR? specifies whether to use colors.
|
||||||
and BRIEF?, well, you know. OUT-PORT and TRS-PORT must be output ports.
|
When BRIEF? is true, the individual test cases results are masked and only the
|
||||||
OUT-PORT defaults to the current output port, while TRS-PORT defaults to a
|
summary is shown. ERRORS-ONLY? reduces the amount of test case metadata
|
||||||
void port, which means no TRS output is logged. SELECT and EXCLUDE may take a
|
logged to only that of the failed test cases. OUT-PORT and TRS-PORT must be
|
||||||
regular expression to select or exclude individual test cases based on their
|
output ports. OUT-PORT defaults to the current output port, while TRS-PORT
|
||||||
names."
|
defaults to a void port, which means no TRS output is logged. SELECT and
|
||||||
|
EXCLUDE may take a regular expression to select or exclude individual test
|
||||||
|
cases based on their names."
|
||||||
|
|
||||||
(define (test-on-test-begin-gnu runner)
|
(define (test-skipped? runner)
|
||||||
;; Procedure called at the start of an individual test case, before the
|
(eq? 'skip (test-result-kind runner)))
|
||||||
;; test expression (and expected value) are evaluated.
|
|
||||||
(let ((result (cute assq-ref (test-result-alist runner) <>)))
|
(define (test-failed? runner)
|
||||||
(format #t "test-name: ~A~%" (result 'test-name))
|
(not (or (test-passed? runner)
|
||||||
(format #t "location: ~A~%"
|
(test-skipped? runner))))
|
||||||
(string-append (result 'source-file) ":"
|
|
||||||
(number->string (result 'source-line))))
|
|
||||||
(test-display "source" (result 'source-form) #:pretty? #t)))
|
|
||||||
|
|
||||||
(define (test-on-test-end-gnu runner)
|
(define (test-on-test-end-gnu runner)
|
||||||
;; Procedure called at the end of an individual test case, when the result
|
;; Procedure called at the end of an individual test case, when the result
|
||||||
|
@ -116,21 +119,29 @@ (define (test-on-test-end-gnu runner)
|
||||||
(let* ((results (test-result-alist runner))
|
(let* ((results (test-result-alist runner))
|
||||||
(result? (cut assq <> results))
|
(result? (cut assq <> results))
|
||||||
(result (cut assq-ref results <>)))
|
(result (cut assq-ref results <>)))
|
||||||
(unless brief?
|
(unless (or brief? (and errors-only? (test-skipped? runner)))
|
||||||
;; Display the result of each test case on the console.
|
;; Display the result of each test case on the console.
|
||||||
(format out-port "~A: ~A - ~A~%"
|
(format out-port "~A: ~A - ~A~%"
|
||||||
(result->string (test-result-kind runner) #:colorize? color?)
|
(result->string (test-result-kind runner) #:colorize? color?)
|
||||||
test-name (test-runner-test-name runner)))
|
test-name (test-runner-test-name runner)))
|
||||||
(when (result? 'expected-value)
|
|
||||||
(test-display "expected-value" (result 'expected-value)))
|
(unless (and errors-only? (not (test-failed? runner)))
|
||||||
(when (result? 'expected-error)
|
(format #t "test-name: ~A~%" (result 'test-name))
|
||||||
(test-display "expected-error" (result 'expected-error) #:pretty? #t))
|
(format #t "location: ~A~%"
|
||||||
(when (result? 'actual-value)
|
(string-append (result 'source-file) ":"
|
||||||
(test-display "actual-value" (result 'actual-value)))
|
(number->string (result 'source-line))))
|
||||||
(when (result? 'actual-error)
|
(test-display "source" (result 'source-form) #:pretty? #t)
|
||||||
(test-display "actual-error" (result 'actual-error) #:pretty? #t))
|
(when (result? 'expected-value)
|
||||||
(format #t "result: ~a~%" (result->string (result 'result-kind)))
|
(test-display "expected-value" (result 'expected-value)))
|
||||||
(newline)
|
(when (result? 'expected-error)
|
||||||
|
(test-display "expected-error" (result 'expected-error) #:pretty? #t))
|
||||||
|
(when (result? 'actual-value)
|
||||||
|
(test-display "actual-value" (result 'actual-value)))
|
||||||
|
(when (result? 'actual-error)
|
||||||
|
(test-display "actual-error" (result 'actual-error) #:pretty? #t))
|
||||||
|
(format #t "result: ~a~%" (result->string (result 'result-kind)))
|
||||||
|
(newline))
|
||||||
|
|
||||||
(format trs-port ":test-result: ~A ~A~%"
|
(format trs-port ":test-result: ~A ~A~%"
|
||||||
(result->string (test-result-kind runner))
|
(result->string (test-result-kind runner))
|
||||||
(test-runner-test-name runner))))
|
(test-runner-test-name runner))))
|
||||||
|
@ -157,7 +168,6 @@ (define (test-on-group-end-gnu runner)
|
||||||
#f))
|
#f))
|
||||||
|
|
||||||
(let ((runner (test-runner-null)))
|
(let ((runner (test-runner-null)))
|
||||||
(test-runner-on-test-begin! runner test-on-test-begin-gnu)
|
|
||||||
(test-runner-on-test-end! runner test-on-test-end-gnu)
|
(test-runner-on-test-end! runner test-on-test-end-gnu)
|
||||||
(test-runner-on-group-end! runner test-on-group-end-gnu)
|
(test-runner-on-group-end! runner test-on-group-end-gnu)
|
||||||
(test-runner-on-bad-end-name! runner test-on-bad-end-name-simple)
|
(test-runner-on-bad-end-name! runner test-on-bad-end-name-simple)
|
||||||
|
@ -225,6 +235,7 @@ (define (main . args)
|
||||||
(test-runner-gnu test-name
|
(test-runner-gnu test-name
|
||||||
#:color? color-tests
|
#:color? color-tests
|
||||||
#:brief? (option->boolean opts 'brief)
|
#:brief? (option->boolean opts 'brief)
|
||||||
|
#:errors-only? (option->boolean opts 'errors-only)
|
||||||
#:out-port out #:trs-port trs)
|
#:out-port out #:trs-port trs)
|
||||||
(test-apply test-specifier
|
(test-apply test-specifier
|
||||||
(lambda _
|
(lambda _
|
||||||
|
|
|
@ -933,6 +933,18 @@ export SCM_LOG_DRIVER_FLAGS="--select=^transaction-upgrade-entry"
|
||||||
make check TESTS="tests/packages.scm"
|
make check TESTS="tests/packages.scm"
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
|
Those wishing to inspect the results of failed tests directly from the
|
||||||
|
command line can add the @option{--errors-only=yes} option to the
|
||||||
|
@code{SCM_LOG_DRIVER_FLAGS} makefile variable and set the @code{VERBOSE}
|
||||||
|
Automake makefile variable, as in:
|
||||||
|
|
||||||
|
@example
|
||||||
|
make check SCM_LOG_DRIVER_FLAGS="--brief=no --errors-only=yes" VERBOSE=1
|
||||||
|
@end example
|
||||||
|
|
||||||
|
@xref{Parallel Test Harness,,,automake,GNU Automake} for more
|
||||||
|
information about the Automake Parallel Test Harness.
|
||||||
|
|
||||||
Upon failure, please email @email{bug-guix@@gnu.org} and attach the
|
Upon failure, please email @email{bug-guix@@gnu.org} and attach the
|
||||||
@file{test-suite.log} file. Please specify the Guix version being used
|
@file{test-suite.log} file. Please specify the Guix version being used
|
||||||
as well as version numbers of the dependencies (@pxref{Requirements}) in
|
as well as version numbers of the dependencies (@pxref{Requirements}) in
|
||||||
|
|
Loading…
Reference in a new issue