diff --git a/pkgs/compiler-pkgs/compiler-lib/compiler/commands/test.rkt b/pkgs/compiler-pkgs/compiler-lib/compiler/commands/test.rkt index e3d583b1dc..8424525255 100644 --- a/pkgs/compiler-pkgs/compiler-lib/compiler/commands/test.rkt +++ b/pkgs/compiler-pkgs/compiler-lib/compiler/commands/test.rkt @@ -31,6 +31,7 @@ (define table? #f) (define fresh-user? #f) (define empty-input? #f) +(define ignore-stderr-patterns null) (define jobs 0) ; 0 mean "default" (define task-sema (make-semaphore 1)) @@ -254,7 +255,10 @@ ;; Check results: (when check-stderr? - (unless (equal? #"" (get-output-bytes e)) + (unless (let ([s (get-output-bytes e)]) + (or (equal? #"" s) + (ormap (lambda (p) (regexp-match? p s)) + ignore-stderr-patterns))) (error 'test "non-empty stderr: ~e" (get-output-bytes e)))) (unless (zero? result-code) (error 'test "non-zero exit: ~e" result-code)) @@ -913,15 +917,21 @@ [("--fresh-user") "Fresh PLTUSERHOME, etc., for each test" (set! fresh-user? #t)] + [("--empty-stdin") + "Call program with an empty stdin" + (set! empty-input? #t)] [("--quiet-program" "-Q") "Quiet the program" (set! quiet-program? #t)] [("--check-stderr" "-e") "Treat stderr output as a test failure" (set! check-stderr? #t)] - [("--empty-stdin") - "Call program with an empty stdin" - (set! empty-input? #t)] + #:multi + [("++ignore-stderr") pattern + "Ignore standard error output if it matches #px\"\"" + (set! ignore-stderr-patterns + (cons (pregexp pattern) ignore-stderr-patterns))] + #:once-each [("--quiet" "-q") "Suppress `raco test: ...' message" (set! quiet? #t)] diff --git a/pkgs/racket-pkgs/racket-doc/scribblings/raco/test.scrbl b/pkgs/racket-pkgs/racket-doc/scribblings/raco/test.scrbl index 3ff92ff36c..264cf58b3c 100644 --- a/pkgs/racket-pkgs/racket-doc/scribblings/raco/test.scrbl +++ b/pkgs/racket-pkgs/racket-doc/scribblings/raco/test.scrbl @@ -113,14 +113,20 @@ The @exec{raco test} command accepts several flags: the add-on directory (which is where packages are installed, for example), does @emph{not} change for each test process.} + @item{@DFlag{empty-stdin} + --- provide an empty stdin to each test program.} + @item{@Flag{Q} or @DFlag{quiet-program} --- suppresses output from each test program.} @item{@Flag{e} or @DFlag{check-stderr} --- count any stderr output as a test failure.} - @item{@DFlag{empty-stdin} - --- provide an empty stdin to each test program.} + @item{@DPFlag{ignore-stderr} @nonterm{pattern} + --- don't count stderr output as a test failure if it matches + @nonterm{pattern}. This flag can be used multiple times, and + stderr output is treated as success as long as it matches any + one @nonterm{pattern}.} @item{@Flag{q} or @DFlag{quiet} --- suppresses output of progress information, responsible