diff --git a/pkgs/compiler-pkgs/compiler-lib/compiler/commands/test.rkt b/pkgs/compiler-pkgs/compiler-lib/compiler/commands/test.rkt index 064aa735fe..4388007656 100644 --- a/pkgs/compiler-pkgs/compiler-lib/compiler/commands/test.rkt +++ b/pkgs/compiler-pkgs/compiler-lib/compiler/commands/test.rkt @@ -94,13 +94,14 @@ 'process))] #:timeout [timeout default-timeout]) (define c (make-custodian)) + (define timeout? #f) (with-handlers ([exn:fail? (lambda (exn) (custodian-shutdown-all c) (unless quiet? (eprintf "~a: ~a\n" (extract-file-name p) (exn-message exn))) - (summary 1 1 (current-label) #f))]) + (summary 1 1 (current-label) #f (if timeout? 1 0)))]) (define e (open-output-bytes)) (define stdout (if quiet-program? @@ -127,6 +128,7 @@ ((executable-yield-handler) 0) (set! done? #t))))) (unless (thread? (sync/timeout timeout t)) + (set! timeout? #t) (error 'test "timeout after ~a seconds" timeout)) (unless done? (error 'test "test raised an exception")) @@ -149,6 +151,7 @@ ;; Wait for the place to finish: (unless (sync/timeout timeout (place-dead-evt pl)) + (set! timeout? #t) (error 'test "timeout after ~a seconds" timeout)) ;; Get result code and test results: @@ -177,6 +180,7 @@ (define proc (list-ref ps 4)) (unless (sync/timeout timeout (thread (lambda () (proc 'wait)))) + (set! timeout? #t) (error 'test "timeout after ~a seconds" timeout)) (define results @@ -200,9 +204,9 @@ (error 'test "non-zero exit: ~e" result-code)) (cond [test-results - (summary (car test-results) (cdr test-results) (current-label) #f)] + (summary (car test-results) (cdr test-results) (current-label) #f 0)] [else - (summary 0 1 (current-label) #f)]))) + (summary 0 1 (current-label) #f 0)]))) ;; For recording stderr while also propagating to the original stderr: (define (tee-output-port p1 p2) @@ -254,7 +258,7 @@ +inf.0))) (define current-label (make-parameter "???")) -(struct summary (failed total label body-res)) +(struct summary (failed total label body-res timeout)) (define-syntax-rule (with-summary label . body) (call-with-summary label (lambda () . body))) @@ -270,7 +274,8 @@ (apply + (map summary-failed res)) (apply + (map summary-total res)) (current-label) - res))) + res + (apply + (map summary-timeout res))))) (define (iprintf i fmt . more) @@ -283,9 +288,9 @@ (match sum [(list sum ...) (append-map flatten sum)] - [(summary failed total `(file ,p) body) + [(summary failed total `(file ,p) body timeout) (list sum)] - [(summary failed total label body) + [(summary failed total label body timeout) (flatten body)] [(? void?) empty]))) @@ -304,7 +309,7 @@ (define failed-wid (max-width summary-failed)) (define total-wid (max-width summary-total)) (for ([f (in-list sfiles)]) - (match-define (summary failed total `(file ,p) _) f) + (match-define (summary failed total `(file ,p) _ _) f) (displayln (~a (~a #:min-width failed-wid #:align 'right (if (zero? failed) @@ -412,7 +417,7 @@ [(directory-exists? p) (set! single-file? #f) (if (omit-path? (path->directory-path p)) - (summary 0 0 #f 0) + (summary 0 0 #f null 0) (with-summary `(directory ,p) (map/parallel @@ -458,7 +463,7 @@ (test-module p file-name args #f #:sema continue-sema))))))))] [(not (file-exists? p)) (error 'test "given path ~e does not exist" p)] - [else (summary 0 0 #f null)])])) + [else (summary 0 0 #f null 0)])])) (module paths racket/base (require setup/link @@ -523,8 +528,11 @@ (define collections? #f) (define packages? #f) +(define check-top-suffix? #f) -(define (test-top e #:sema continue-sema) +(define (test-top e + #:check-suffix? check-suffix? + #:sema continue-sema) (cond [collections? (match (collection-paths e) @@ -542,7 +550,9 @@ (test-files pd #:sema continue-sema)) (error 'test "Package ~e is not installed" e))] [else - (test-files e #:sema continue-sema)])) + (test-files e + #:check-suffix? check-suffix? + #:sema continue-sema)])) ;; -------------------------------------------------- ;; Reading "info.rkt" files @@ -646,9 +656,14 @@ [("--package" "-p") "Interpret arguments as packages" (set! packages? #t)] + [("--modules" "-m") + ("Interpret arguments as modules" + " (ignore argument unless \".rkt\", \".scrbl\", or enabled by \"info.rkt\")") + (set! check-top-suffix? #t)] #:once-each [("--drdr") "Configure defaults to imitate DrDr" + (set! check-top-suffix? #t) (set! first-avail? #t) (when (zero? jobs) (set-jobs! (processor-count))) @@ -710,7 +725,11 @@ (define sum ;; The #:sema argument everywhre makes tests start ;; in a deterministic order: - (map/parallel test-top file-or-directory + (map/parallel (lambda (f #:sema s) + (test-top f + #:check-suffix? check-top-suffix? + #:sema s)) + file-or-directory #:sema (make-semaphore))) (when table? (display-summary sum)) @@ -724,5 +743,9 @@ (for ([i (in-range (- (summary-total s) (summary-failed s)))]) (test-log! #t)))) - (define r (test-log #:display? #t #:exit? #t)) - (exit (if (zero? (car r)) 0 1)))) + (test-log #:display? #t #:exit? #f) + (define sum1 (call-with-summary #f (lambda () sum))) + (exit (cond + [(positive? (summary-timeout sum1)) 2] + [(positive? (summary-failed sum1)) 1] + [else 0])))) diff --git a/pkgs/racket-pkgs/racket-doc/scribblings/raco/test.scrbl b/pkgs/racket-pkgs/racket-doc/scribblings/raco/test.scrbl index 13274f51be..e4e1c5d55f 100644 --- a/pkgs/racket-pkgs/racket-doc/scribblings/raco/test.scrbl +++ b/pkgs/racket-pkgs/racket-doc/scribblings/raco/test.scrbl @@ -39,9 +39,18 @@ The @exec{raco test} command accepts several flags: be tested. (All package scopes are searched for the first, most specific package.)} + @item{@Flag{m} or @DFlag{modules} + --- Not only interprets the arguments as paths (which is the + default mode), but treats them the same as a path found in a + directory, which means ignoring a file argument that does not + have the extension @filepath{.rkt}, have the extension + @filepath{.scrbl}, or is enabled explicitly via + @racket[test-command-line-arguments] in an @filepath{info.rkt} + file.} + @item{@DFlag{drdr} --- Configures defaults to imitate the DrDr continuous testing - system: use as many jobs as available processors, set the + system: ignore non-modules, use as many jobs as available processors, set the default timeout to 90 seconds, count stderr output as a test failure, quiet program output, and print a table of results.} @@ -84,7 +93,9 @@ The @exec{raco test} command accepts several flags: @item{@DFlag{timeout} @nonterm{seconds} --- Sets the default timeout (after which a test counts as failed) to @nonterm{seconds}. Use @exec{+inf.0} to allow tests to run without - limit but allow @racket[timeout] sub-submodule configuration.} + limit but allow @racket[timeout] sub-submodule configuration. + If any test fails due to a timeout, the exit status of @exec{raco test} + is 2 (as opposed to 1 for only non-timeout failures or 0 for success).} @item{@Flag{Q} or @DFlag{quiet-program} --- suppresses output from each test program.}