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/collects
|
||||||
setup/getinfo)
|
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 submodules '()) ; '() means "default"
|
||||||
(define first-avail? #f)
|
(define first-avail? #f)
|
||||||
(define run-anyways? #t)
|
(define run-anyways? #t)
|
||||||
|
@ -384,7 +388,8 @@
|
||||||
m))
|
m))
|
||||||
(apply string-append
|
(apply string-append
|
||||||
(for/list ([a (in-list args)])
|
(for/list ([a (in-list args)])
|
||||||
(format " ~s" (format "~a" a))))))
|
(format " ~s" (format "~a" a)))))
|
||||||
|
(flush-output))
|
||||||
id)))
|
id)))
|
||||||
(begin0
|
(begin0
|
||||||
(dynamic-require* mod 0 args try-config?)
|
(dynamic-require* mod 0 args try-config?)
|
||||||
|
@ -419,7 +424,8 @@
|
||||||
#:sema continue-sema)))]
|
#:sema continue-sema)))]
|
||||||
[(and (file-exists? p)
|
[(and (file-exists? p)
|
||||||
(or (not check-suffix?)
|
(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)))
|
(not (omit-path? p)))
|
||||||
(define args (get-cmdline p))
|
(define args (get-cmdline p))
|
||||||
(parameterize ([current-directory (let-values ([(base name dir?) (split-path p)])
|
(parameterize ([current-directory (let-values ([(base name dir?) (split-path p)])
|
||||||
|
@ -616,9 +622,9 @@
|
||||||
(and (path? base)
|
(and (path? base)
|
||||||
(omit-path? base))))))
|
(omit-path? base))))))
|
||||||
|
|
||||||
(define (get-cmdline p)
|
(define (get-cmdline p [default null])
|
||||||
(let ([p (normalize-info-path p)])
|
(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
|
scribble/bnf
|
||||||
"common.rkt"
|
"common.rkt"
|
||||||
(for-label racket/runtime-path
|
(for-label racket/runtime-path
|
||||||
launcher/launcher))
|
launcher/launcher
|
||||||
|
rackunit/log))
|
||||||
|
|
||||||
@title[#:tag "test"]{@exec{raco test}: Run tests}
|
@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.
|
tests as processes or places.
|
||||||
|
|
||||||
When an argument path refers to a directory, the tool recursively
|
When an argument path refers to a directory, the tool recursively
|
||||||
discovers all files that end in @filepath{.rkt} within the directory
|
discovers and runs all files within the directory that end in
|
||||||
and runs them.
|
@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
|
A test is counted as failing if it logs a failing test code via
|
||||||
non-zero exit code or (when @Flag{e} or @DFlag{check-stderr} is
|
@racket[test-log], causes Racket to exit with a non-zero exit code, or
|
||||||
specified) if it produces output on the error port. The current
|
(when @Flag{e} or @DFlag{check-stderr} is specified) if it produces
|
||||||
directory is set to a test file's directory before running the file.
|
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:
|
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}
|
@item{@DFlag{table} or @Flag{t}
|
||||||
--- Print a summary table after all tests. If a test uses
|
--- Print a summary table after all tests. If a test uses
|
||||||
@racketmodname[rackunit], or if a test at least uses
|
@racketmodname[rackunit], or if a test at least uses
|
||||||
@racketmodname[rackunit/log] to log successes and failures,
|
@racket[test-log] from @racketmodname[rackunit/log] to log
|
||||||
the table reports test and failure counts based
|
successes and failures, the table reports test and failure
|
||||||
on the log.}
|
counts based on the log.}
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user