diff --git a/cover.rkt b/cover.rkt index 0a8cb82..0134bea 100644 --- a/cover.rkt +++ b/cover.rkt @@ -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))) diff --git a/main.rkt b/main.rkt index 8a76710..0330ad6 100644 --- a/main.rkt +++ b/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? diff --git a/raco.rkt b/raco.rkt index 6b55ade..83be241 100644 --- a/raco.rkt +++ b/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) diff --git a/scribblings/api.scrbl b/scribblings/api.scrbl index c5ab750..bcfbf75 100644 --- a/scribblings/api.scrbl +++ b/scribblings/api.scrbl @@ -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.} diff --git a/scribblings/basics.scrbl b/scribblings/basics.scrbl index 03254a7..1e2856d 100644 --- a/scribblings/basics.scrbl +++ b/scribblings/basics.scrbl @@ -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.} ]