raco test: run ".scrbl" files by default; check cmdline args for all files
To test a file that ends in".ss", ".scm", etc., add a `test-command-line-arguments` entry to an "info.rkt" file.
This commit is contained in:
parent
fee479e2fa
commit
e44b15c032
|
@ -17,6 +17,10 @@
|
|||
setup/collects
|
||||
setup/getinfo)
|
||||
|
||||
(define rx:default-suffixes #rx#"\\.(?:rkt|scrbl)$")
|
||||
;; For any other file suffix, a `test-command-line-arguments`
|
||||
;; entry is required in "info.rkt".
|
||||
|
||||
(define submodules '()) ; '() means "default"
|
||||
(define first-avail? #f)
|
||||
(define run-anyways? #t)
|
||||
|
@ -384,7 +388,8 @@
|
|||
m))
|
||||
(apply string-append
|
||||
(for/list ([a (in-list args)])
|
||||
(format " ~s" (format "~a" a))))))
|
||||
(format " ~s" (format "~a" a)))))
|
||||
(flush-output))
|
||||
id)))
|
||||
(begin0
|
||||
(dynamic-require* mod 0 args try-config?)
|
||||
|
@ -419,7 +424,8 @@
|
|||
#:sema continue-sema)))]
|
||||
[(and (file-exists? p)
|
||||
(or (not check-suffix?)
|
||||
(regexp-match #rx#"\\.rkt$" (path->bytes p)))
|
||||
(regexp-match rx:default-suffixes p)
|
||||
(get-cmdline p #f))
|
||||
(not (omit-path? p)))
|
||||
(define args (get-cmdline p))
|
||||
(parameterize ([current-directory (let-values ([(base name dir?) (split-path p)])
|
||||
|
@ -616,9 +622,9 @@
|
|||
(and (path? base)
|
||||
(omit-path? base))))))
|
||||
|
||||
(define (get-cmdline p)
|
||||
(define (get-cmdline p [default null])
|
||||
(let ([p (normalize-info-path p)])
|
||||
(hash-ref command-line-arguments p null)))
|
||||
(hash-ref command-line-arguments p default)))
|
||||
|
||||
;; --------------------------------------------------
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
scribble/bnf
|
||||
"common.rkt"
|
||||
(for-label racket/runtime-path
|
||||
launcher/launcher))
|
||||
launcher/launcher
|
||||
rackunit/log))
|
||||
|
||||
@title[#:tag "test"]{@exec{raco test}: Run tests}
|
||||
|
||||
|
@ -15,13 +16,16 @@ to run the main module if no submodule is found, and whether to run
|
|||
tests as processes or places.
|
||||
|
||||
When an argument path refers to a directory, the tool recursively
|
||||
discovers all files that end in @filepath{.rkt} within the directory
|
||||
and runs them.
|
||||
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
|
||||
@racket[test-command-line-arguments] in an @filepath{info.rkt} file.
|
||||
|
||||
A test is counted as failing if it causes Racket to exit with a
|
||||
non-zero exit code or (when @Flag{e} or @DFlag{check-stderr} is
|
||||
specified) if it produces output on the error port. The current
|
||||
directory is set to a test file's directory before running the 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
|
||||
(when @Flag{e} or @DFlag{check-stderr} is specified) if it produces
|
||||
output on the error port. The current directory is set to a test
|
||||
file's directory before running the file.
|
||||
|
||||
The @exec{raco test} command accepts several flags:
|
||||
|
||||
|
@ -94,9 +98,9 @@ The @exec{raco test} command accepts several flags:
|
|||
@item{@DFlag{table} or @Flag{t}
|
||||
--- Print a summary table after all tests. If a test uses
|
||||
@racketmodname[rackunit], or if a test at least uses
|
||||
@racketmodname[rackunit/log] to log successes and failures,
|
||||
the table reports test and failure counts based
|
||||
on the log.}
|
||||
@racket[test-log] from @racketmodname[rackunit/log] to log
|
||||
successes and failures, the table reports test and failure
|
||||
counts based on the log.}
|
||||
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user