racket/slice, expand raco test, remove begin-for-testing

original commit: f8325776cf
This commit is contained in:
Jay McCarthy 2012-03-09 19:51:42 -07:00
parent 9741ae6d98
commit 98fa97ae26

View File

@ -4,25 +4,41 @@
racket/path racket/path
raco/command-name) raco/command-name)
(define submodule 'test)
(define run-anyways? #f)
(define do-test (define do-test
(match-lambda (match-lambda
[(? string? s) [(? string? s)
(do-test (string->path s))] (do-test (string->path s))]
[(? path? p) [(? path? p)
(define ps (path->string p))
(cond (cond
[(directory-exists? p) [(directory-exists? p)
(for-each (for-each
(λ (dp) (λ (dp)
(do-test (build-path p dp))) (do-test (build-path p dp)))
(directory-list p))] (directory-list p))]
[(file-exists? p) [(and (file-exists? p)
(define mod `(submod (file ,(path->string p)) test)) (regexp-match #rx"\\.rkt$" ps))
(when (module-declared? mod #t) (define fmod `(file ,ps))
(dynamic-require mod #f))] (define mod `(submod ,fmod ,submodule))
[else (cond
[(module-declared? mod #t)
(dynamic-require mod #f)]
[(and run-anyways? (module-declared? fmod #t))
(dynamic-require fmod #f)])]
[(not (file-exists? p))
(error 'test "Given path ~e does not exist" p)])])) (error 'test "Given path ~e does not exist" p)])]))
(command-line (command-line
#:program (short-program+command-name) #:program (short-program+command-name)
#:once-each
[("--submodule" "-s") submodule-str
"Determines which submodule to load"
(set! submodule (string->symbol submodule-str))]
[("--run-if-absent" "-r")
"When set, raco test will require the default module if the given submodule is not present."
(set! run-anyways? #t)]
#:args files+directories #:args files+directories
(for-each do-test files+directories)) (for-each do-test files+directories))