diff --git a/pkgs/compiler-lib/compiler/commands/test.rkt b/pkgs/compiler-lib/compiler/commands/test.rkt index 7416398815..ddb0755d79 100644 --- a/pkgs/compiler-lib/compiler/commands/test.rkt +++ b/pkgs/compiler-lib/compiler/commands/test.rkt @@ -121,6 +121,7 @@ 'direct 'process))] #:timeout timeout + #:ignore-stderr ignore-stderr #:responsible responsible #:lock-name lock-name #:random? random?) @@ -271,7 +272,9 @@ (unless (let ([s (get-output-bytes e)]) (or (equal? #"" s) (ormap (lambda (p) (regexp-match? p s)) - ignore-stderr-patterns))) + ignore-stderr-patterns) + (and ignore-stderr + (regexp-match? ignore-stderr s)))) (parameterize ([error-print-width 16384]) (error test-exe-name "non-empty stderr: ~e" (get-output-bytes e))))) (unless (zero? result-code) @@ -331,6 +334,7 @@ #:try-config? try-config? #:args args #:timeout timeout + #:ignore-stderr ignore-stderr #:responsible responsible #:lock-name lock-name #:random? random?) @@ -350,6 +354,8 @@ (lookup 'timeout (lambda () timeout)) +inf.0) + #:ignore-stderr (lookup 'ignore-stderr + (lambda () ignore-stderr)) #:lock-name (lookup 'lock-name (lambda () lock-name)) #:random? (lookup 'random? @@ -473,6 +479,7 @@ #:try-config? try-config? #:args [args '()] #:timeout [timeout +inf.0] + #:ignore-stderr [ignore-stderr #f] #:responsible [responsible #f] #:lock-name [lock-name #f] #:random? [random? #f]) @@ -527,6 +534,7 @@ #:try-config? try-config? #:args args #:timeout timeout + #:ignore-stderr ignore-stderr #:responsible responsible #:lock-name lock-name #:random? random?) @@ -577,6 +585,7 @@ (define norm-p (normalize-info-path p)) (define args (get-cmdline norm-p)) (define timeout (get-timeout norm-p)) + (define ignore-stderr (get-ignore-stderr norm-p)) (define lock-name (get-lock-name norm-p)) (define responsible (get-responsible norm-p)) (define random? (get-random norm-p)) @@ -591,6 +600,7 @@ #:sema continue-sema #:args args #:timeout timeout + #:ignore-stderr ignore-stderr #:responsible responsible #:lock-name lock-name #:random? random?)) @@ -765,6 +775,7 @@ (define command-line-arguments (make-hash)) (define timeouts (make-hash)) (define lock-names (make-hash)) +(define ignore-stderrs (make-hash)) (define responsibles (make-hash)) (define randoms (make-hash)) @@ -849,7 +860,14 @@ #:ok-all? #t) (get-keyed randoms 'test-random - (lambda (v) (string? v)))))) + (lambda (v) (string? v))) + (get-keyed ignore-stderrs + 'test-ignore-stderrs + (lambda (v) (or (string? v) + (bytes? v) + (regexp? v) + (byte-regexp? v))) + #:ok-all? #t)))) (define (check-info/parents dir subpath) (let loop ([dir dir] [subpath subpath]) @@ -902,13 +920,13 @@ ;; assumes `(check-info p)` has been called and `p` is normalized (hash-ref lock-names p #f)) +(define (get-ignore-stderr p) + ;; assumes `(check-info p)` has been called and `p` is normalized + (hash-ref/check-parents ignore-stderrs p)) + (define (get-responsible p) ;; assumes `(check-info p)` has been called and `p` is normalized - (or (let loop ([p p]) - (or (hash-ref responsibles p #f) - (let-values ([(base name dir?) (split-path p)]) - (and (path? base) - (loop base))))) + (or (hash-ref/check-parents responsibles p) ;; Check package authors: (let-values ([(pkg subpath) (path->pkg+subpath p #:cache pkg-cache)]) (and pkg @@ -923,6 +941,13 @@ (and (ok-responsible? v) v)))))))) +(define (hash-ref/check-parents ht p) + (let loop ([p p]) + (or (hash-ref ht p #f) + (let-values ([(base name dir?) (split-path p)]) + (and (path? base) + (loop base)))))) + (define (get-random p) ;; assumes `(check-info p)` has been called and `p` is normalized (hash-ref randoms p #f)) diff --git a/pkgs/compiler-lib/info.rkt b/pkgs/compiler-lib/info.rkt index cce80f1f4a..53ed99363f 100644 --- a/pkgs/compiler-lib/info.rkt +++ b/pkgs/compiler-lib/info.rkt @@ -13,4 +13,4 @@ (define pkg-authors '(mflatt)) -(define version "1.4") +(define version "1.5") diff --git a/pkgs/racket-doc/scribblings/raco/test.scrbl b/pkgs/racket-doc/scribblings/raco/test.scrbl index f3560b7b62..d87431895c 100644 --- a/pkgs/racket-doc/scribblings/raco/test.scrbl +++ b/pkgs/racket-doc/scribblings/raco/test.scrbl @@ -10,6 +10,9 @@ @title[#:tag "test"]{@exec{raco test}: Run tests} +@; For `history` to connect to the "compiler-lib" package: +@declare-exporting[compiler/commands/test] + The @exec{raco test} command requires and runs the (by default) @racket[test] submodule associated with each path given on the command line. Command-line flags can control which submodule is run, whether to @@ -193,6 +196,11 @@ identifiers: @envvar{PLTLOCKTIME} environment variable or defaults to 4 hours.} + @item{@racket[ignore-stderr] --- a string, byte string, or + @tech[#:doc reference-doc]{regexp value}, as a pattern that + causes error output to not be treated as a failure if the + output matches the pattern.} + @item{@racket[random?] --- if true, indicates that the test's output is expected to vary. See @secref["test-responsible"].} @@ -213,6 +221,8 @@ instance, a file might look like this: (module test racket/base) ) +@history[#:changed "1.5" @elem{Added @racket[ignore-stderr] support.}] + @section[#:tag "test-config-info"]{Test Configuration by @filepath{info.rkt}} Submodule-based test configuration is preferred (see @@ -272,6 +282,14 @@ The following @filepath{info.rkt} fields are recognized: for @racket[_module-path-string]. See @racket[lock-name] in @secref["test-config"].} + @item{@racket[test-ignore-stderrs] --- a list of @racket[(list + _module-path-string _pattern)] or @racket[(list 'all _pattern)] + to declare patterns of standard error output that are allowed a + non-failures for @racket[_module-path-string] or all files + within the directory. Each @racket[_pattern] must be a string, + byte string, or @tech[#:doc reference-doc]{regexp value}. See + @racket[ignore-stderr] in @secref["test-config"].} + @item{@racket[test-randoms] --- a list of path strings (relative to the enclosing directory) for modules whose output varies. See @secref["test-responsible"].} @@ -281,6 +299,8 @@ The following @filepath{info.rkt} fields are recognized: ] +@history[#:changed "1.5" @elem{Added @racket[test-ignore-stderrs] support.}] + @section[#:tag "test-responsible"]{Responsible-Party and Varying-Output Logging} When a test has a declared responsible party, then the test's output