added submodule control (Issue 16)
This commit is contained in:
parent
3a7e3d3973
commit
17719434b6
|
@ -19,7 +19,7 @@
|
|||
;; PathString * -> Boolean
|
||||
;; Test files and build coverage map
|
||||
;; returns true if all tests passed
|
||||
(define (test-files! . paths)
|
||||
(define (test-files! #:submod [submod-name 'test] . paths)
|
||||
(for ([path paths])
|
||||
(define p
|
||||
(if (absolute-path? path)
|
||||
|
@ -52,7 +52,7 @@
|
|||
(apply old-check x))])
|
||||
(eval `(dynamic-require '(file ,p) #f))
|
||||
(namespace-require `(file ,p))
|
||||
(define submod `(submod (file ,p) test))
|
||||
(define submod `(submod (file ,p) ,submod-name))
|
||||
(when (module-declared? submod)
|
||||
(namespace-require submod)))))
|
||||
(not tests-failed)))
|
||||
|
|
2
main.rkt
2
main.rkt
|
@ -5,7 +5,7 @@
|
|||
(contract-out
|
||||
[coverage/c contract?]
|
||||
[file-coverage/c contract?]
|
||||
[test-files! (->* () () #:rest (listof path-string?) any/c)]
|
||||
[test-files! (->* () (#:submod symbol?) #:rest (listof path-string?) any/c)]
|
||||
[clear-coverage! (-> any)]
|
||||
[get-test-coverage (-> coverage/c)]
|
||||
[make-covered?
|
||||
|
|
6
raco.rkt
6
raco.rkt
|
@ -12,6 +12,7 @@
|
|||
(define output-format "html")
|
||||
(define exclude-paths '())
|
||||
(define include-exts '())
|
||||
(define submod 'test)
|
||||
|
||||
(define args
|
||||
(command-line
|
||||
|
@ -36,6 +37,9 @@
|
|||
[("-i" "--include-extentions") f
|
||||
"include these extentions in files to cover."
|
||||
(set! include-exts (cons f include-exts))]
|
||||
[("-s" "--submodule") s
|
||||
"Run the given submodule instead of the test submodule"
|
||||
(set! submod (string->symbol s))]
|
||||
#:args (file . files)
|
||||
(cons file files)))
|
||||
(define files (expand-directories args include-exts))
|
||||
|
@ -46,7 +50,7 @@
|
|||
[("raw") generate-raw-coverage]
|
||||
[else (error 'cover "given unknown coverage output format: ~s" output-format)]))
|
||||
(printf "generating test coverage for ~s\n" files)
|
||||
(define passed (apply test-files! files))
|
||||
(define passed (keyword-apply test-files! '(#:submod) (list submod) files))
|
||||
(define coverage (remove-excluded-paths (get-test-coverage) exclude-paths))
|
||||
(printf "dumping coverage info into ~s\n" coverage-dir)
|
||||
(generate-coverage coverage coverage-dir)
|
||||
|
|
|
@ -9,11 +9,12 @@ In addition to a raco tool Cover provides racket bindings for running
|
|||
tests and collecting coverage information. The following are the basic
|
||||
functions of test coverage.
|
||||
|
||||
@defproc[(test-files! (files path-string?) ...) any/c]{
|
||||
@defproc[(test-files! (#:submod submod symbol? 'test) (files path-string?) ...) any/c]{
|
||||
|
||||
Tests all given @racket[files] and stores the coverage information. Returns
|
||||
false if tests failed. Test coverage information is still collected when test
|
||||
fail. Test coverage info is added to existing coverage info.}
|
||||
Runs all given @racket[files] and there submodule @racket[submod] (if it exitsts),
|
||||
storing the coverage information. Returns false if tests failed. Test coverage
|
||||
information is still collected when test fail. Test coverage info is added to
|
||||
existing coverage info.}
|
||||
|
||||
@defproc[(clear-coverage!) any]{Clears all coverage information.}
|
||||
|
||||
|
|
|
@ -37,4 +37,6 @@ The @exec{raco cover} command accepts the following flags:
|
|||
used when expanding directories, searching for files to cover.}
|
||||
@item{@Flag{v} or @DFlag{verbose}
|
||||
--- enable verbose logging}
|
||||
@item{@Flag{s} or @DFlag{submod}
|
||||
--- run the given submodule instead of the test submodule.}
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue
Block a user