From 1715a50c80d0bc07092d8ab05ee4812cb7cad399 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 3 Jun 2014 11:35:48 +0100 Subject: [PATCH] raco test: refine override-"info.rkt" behavior of specifying a file In consultation with Jay, unify the ignore-file's-extension and ignore-"info.rkt"-disabling treatment of `raco test` arguments. The change is that the latter applies only when an argument is a file, and not when it's a directory. --- .../compiler-lib/compiler/commands/test.rkt | 39 ++++++++++++------- .../racket-doc/scribblings/raco/test.scrbl | 36 ++++++++++------- 2 files changed, 45 insertions(+), 30 deletions(-) diff --git a/pkgs/compiler-pkgs/compiler-lib/compiler/commands/test.rkt b/pkgs/compiler-pkgs/compiler-lib/compiler/commands/test.rkt index 9c4a04bd6a..36e13d49cf 100644 --- a/pkgs/compiler-pkgs/compiler-lib/compiler/commands/test.rkt +++ b/pkgs/compiler-pkgs/compiler-lib/compiler/commands/test.rkt @@ -533,11 +533,12 @@ [(and (file-exists? p) (or (not check-suffix?) (regexp-match rx:default-suffixes p) - (get-cmdline p #f)) - (or explicit-arguments? - (begin (check-info p) - (not (omit-path? p))))) - ;; The above `omit-path?` loads "info.rkt" files + (get-cmdline p #f #:check-info? #t)) + (or (not check-suffix?) + (not (omit-path? p #:check-info? #t)))) + (unless check-suffix? + ;; make sure "info.rkt" information is loaded: + (check-info p)) (define norm-p (normalize-info-path p)) (define args (get-cmdline norm-p)) (define timeout (get-timeout norm-p)) @@ -657,7 +658,6 @@ (require (submod "." paths)) (define collections? #f) -(define explicit-arguments? #f) (define packages? #f) (define libraries? #f) (define check-top-suffix? #f) @@ -806,21 +806,30 @@ (define (normalize-info-path p) (simplify-path (path->complete-path p) #f)) -(define (omit-path? p) +(define (omit-path? p #:check-info? [check-info? #f]) + (when check-info? (check-info p)) (let ([p (normalize-info-path p)]) (or (hash-ref omit-paths p #f) (let-values ([(base name dir?) (split-path p)]) (and (path? base) (omit-path? base)))))) -(define (get-cmdline p [default null]) - (hash-ref command-line-arguments p default)) +(define (get-cmdline p [default null] #:check-info? [check-info? #f]) + (when check-info? (check-info p)) + (hash-ref command-line-arguments + (if check-info? (normalize-info-path p) p) + default)) -(define (get-timeout p) (hash-ref timeouts p +inf.0)) +(define (get-timeout p) + ;; assumes `(check-info p)` has been called and `p` is normalized + (hash-ref timeouts p +inf.0)) -(define (get-lock-name p) (hash-ref lock-names p #f)) +(define (get-lock-name p) + ;; assumes `(check-info p)` has been called and `p` is normalized + (hash-ref lock-names p #f)) (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)]) @@ -840,7 +849,9 @@ (and (ok-responsible? v) v)))))))) -(define (get-random p) (hash-ref randoms p #f)) +(define (get-random p) + ;; assumes `(check-info p)` has been called and `p` is normalized + (hash-ref randoms p #f)) (define (ok-responsible? v) (or (string? v) @@ -950,9 +961,7 @@ "Print a summary table" (set! table? #t)] #:args file-or-directory - (begin (set! explicit-arguments? - (not (or collections? libraries? packages? check-top-suffix?))) - (unless (= 1 (length file-or-directory)) + (begin (unless (= 1 (length file-or-directory)) (set! single-file? #f)) (define sum ;; The #:sema argument everywhre makes tests start diff --git a/pkgs/racket-pkgs/racket-doc/scribblings/raco/test.scrbl b/pkgs/racket-pkgs/racket-doc/scribblings/raco/test.scrbl index 264cf58b3c..03ba7f6109 100644 --- a/pkgs/racket-pkgs/racket-doc/scribblings/raco/test.scrbl +++ b/pkgs/racket-pkgs/racket-doc/scribblings/raco/test.scrbl @@ -17,11 +17,14 @@ directly, in separate processes (the default), or in separate places. The current directory is set to a test file's directory before running the file. -When an argument path refers to a directory, the tool recursively -discovers and runs all files within the directory that end in -@filepath{.rkt}, end in @filepath{.scrbl}, or have a -(possibly empty) list of arguments-line provided by +When an argument path refers to a directory, @exec{raco test} +recursively discovers and runs all files within the directory that end +in @filepath{.rkt}, end in @filepath{.scrbl}, or have a (possibly +empty) list of command-line arguments provided by @racket[test-command-line-arguments] in an @filepath{info.rkt} file. +At the same time, @exec{raco test} omits files and directories within +a directory as directed by @racket[test-omit-paths] in an +@filepath{info.rkt} file. A test is counted as failing if it logs a failing test code via @racket[test-log!], causes Racket to exit with a non-zero exit code, or @@ -33,24 +36,27 @@ The @exec{raco test} command accepts several flags: @itemize[ @item{@Flag{c} or @DFlag{collection} - --- Interprets the arguments as collections where whose files should be tested.} + --- Interprets the arguments as collections whose content + should be tested (in the same way as directory content).} @item{@Flag{p} or @DFlag{package} - --- Interprets the arguments as packages whose files should - be tested. (All package scopes are searched for the first, most - specific package.)} + --- Interprets the arguments as packages whose contents should + be tested (in the same way as directory content). All package + scopes are searched for the first, most specific @tech[#:doc + '(lib "pkg/scribblings/pkg.scrbl")]{package scope}.} @item{@Flag{l} or @DFlag{lib} - --- Interprets the arguments as packages whose libraries to be tested.} + --- Interprets the arguments as libraries that should be tested.} @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 + default mode), but treats them the same as paths 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 + have the extension @filepath{.rkt}, does not have the extension + @filepath{.scrbl}, or is not enabled explicitly via @racket[test-command-line-arguments] in an @filepath{info.rkt} - file.} + file; meanwhile, paths that are otherwise enabled can be disabled + via @racket[test-omit-paths] in an @filepath{info.rkt} file.} @item{@DFlag{drdr} --- Configures defaults to imitate the DrDr continuous testing @@ -60,7 +66,7 @@ The @exec{raco test} command accepts several flags: create a fresh @envvar{PLTUSERHOME} and @envvar{TMPDIR} for each test, count stderr output as a test failure, quiet program output, - provide program empty input, + provide empty program input, and print a table of results.} @item{@Flag{s} @nonterm{name} or @DFlag{submodule} @nonterm{name} @@ -111,7 +117,7 @@ The @exec{raco test} command accepts several flags: directory and sets @envvar{PLTUSERHOME} and @envvar{TMPDIR}. The @envvar{PLTADDONDIR} environment variable is also set so that the add-on directory (which is where packages are installed, for - example), does @emph{not} change for each test process.} + example) does @emph{not} change for each test process.} @item{@DFlag{empty-stdin} --- provide an empty stdin to each test program.}