adjust raco test so that it accepts multiple -s arguments on the command-line

This is, afaict, a completely backwards compatible way to add this
functionality in the sense that any of the non-error command-line
arguments passed to raco test before still do precisely the same
things

original commit: 9fd4698be9
This commit is contained in:
Robby Findler 2013-02-03 13:11:12 -06:00
parent 06eb0e67e2
commit 81b3b34895

View File

@ -5,8 +5,9 @@
raco/command-name raco/command-name
planet2/lib) planet2/lib)
(define submodule 'test) (define submodules '())
(define run-anyways? #t) (define run-anyways? #t)
(define quiet? #f)
(define (do-test e [check-suffix? #f]) (define (do-test e [check-suffix? #f])
(match e (match e
@ -22,15 +23,22 @@
[(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#"\\.rkt$" (path->bytes p))))
(printf "testing ~a\n" p) (define something-wasnt-declared? #f)
(define mod `(submod ,p ,submodule)) (unless quiet?
(cond (printf "testing ~a\n" p))
[(module-declared? mod #t) (for ([submodule (in-list (if (null? submodules)
(dynamic-require mod #f)] '(test)
[(and run-anyways? (module-declared? p #t)) (reverse submodules)))])
(dynamic-require p #f)])] (define mod `(submod ,p ,submodule))
(cond
[(module-declared? mod #t)
(dynamic-require mod #f)]
[else
(set! something-wasnt-declared? #t)]))
(when (and run-anyways? something-wasnt-declared?)
(dynamic-require p #f))]
[(not (file-exists? p)) [(not (file-exists? p))
(error 'test "Given path ~e does not exist" p)])])) (error 'test "given path ~e does not exist" p)])]))
(module paths racket/base (module paths racket/base
(require setup/link (require setup/link
@ -106,16 +114,21 @@
(command-line (command-line
#:program (short-program+command-name) #:program (short-program+command-name)
#:once-each #:multi
[("--submodule" "-s") name [("--submodule" "-s") name
"Runs submodule <name> (defaults to `test')" "Runs submodule <name>\n (defaults to running just the `test' submodule)"
(set! submodule (string->symbol name))] (let ([n (string->symbol name)])
(set! submodules (cons n submodules)))]
#:once-each
[("--run-if-absent" "-r") [("--run-if-absent" "-r")
"Require module if submodule is absent (on by default)" "Require module if submodule is absent (on by default)"
(set! run-anyways? #t)] (set! run-anyways? #t)]
[("--no-run-if-absent" "-x") [("--no-run-if-absent" "-x")
"Require nothing if submodule is absent" "Require nothing if submodule is absent"
(set! run-anyways? #f)] (set! run-anyways? #f)]
[("--quiet" "-q")
"Suppress `Running ...' message"
(set! quiet? #t)]
#:once-any #:once-any
[("--collection" "-c") [("--collection" "-c")
"Interpret arguments as collections" "Interpret arguments as collections"