Allow multiple output formats, by specifying f several times on the command-line, e.g. raco cover -f html -f coveralls file.rkt.

This commit is contained in:
Georges Dupéron 2016-01-16 14:47:44 +01:00
parent 7a5e12cd42
commit 64cd769fbe
3 changed files with 18 additions and 13 deletions

View File

@ -96,9 +96,9 @@ Thus, In essence this module has three responsibilites:
(compile-file f))
(for*/fold ([tests-failed #f])
([f (in-list abs)]
[submod-name (in-list (if (symbol? submod-names)
(list submod-names)
submod-names))])
[submod-name (in-list (if (list? submod-names)
submod-names
(list submod-names)))])
(printf "cover: running file: ~a\n" f)
(define failed? (handle-file f submod-name))
(or failed? tests-failed)))))

View File

@ -21,7 +21,7 @@
(module+ main
(define coverage-dir "coverage")
(define output-format "html")
(define output-formats "html")
(define exclude-paths '())
(define include-exts '())
(define submods 'test)
@ -36,9 +36,6 @@
[("-d" "--directory") d
"Specify output directory. Defaults to ./coverage."
(set! coverage-dir d)]
[("-f" "--format") format
"Specify that coverage should be run and optional what format. Defaults to html."
(set! output-format format)]
[("-v" "--verbose")
"Verbose mode"
(set! verbose #t)]
@ -46,6 +43,9 @@
"exclude info.rkt, the tests directory, and the scribblings directory from the coverage report"
(set! exclude-paths (list* "info.rkt" "tests" "scribblings" exclude-paths))]
#:multi
[("-f" "--format") format
"Specify that coverage should be run and optionally what formats. Defaults to html."
(set! output-formats (cons format (if (list? output-formats) output-formats '())))]
[("-n" "--no-output-for-path") t
"exclude any paths named this from the coverage report."
(set! exclude-paths (cons t exclude-paths))]
@ -54,7 +54,7 @@
(set! include-exts (cons f include-exts))]
[("-s" "--submodule") s
"Run the given submodule instead of the test submodule."
(set! submods (cons (string->symbol s) (if (symbol? submods) '() submods)))]
(set! submods (cons (string->symbol s) (if (list? submods) submods '())))]
[("-e" "--irrelevant-submodules") s
"Consider the given submodules irrelevant when generating coverage. If not provided defaults to all submodules."
(unless irrel-submods
@ -91,9 +91,14 @@
(expand-directories (map pkg-directory a) b))]))
(define files (path-expand args include-exts))
(define cleaned-files (remove-excluded-paths files exclude-paths))
(define generate-coverage
(hash-ref (get-formats) output-format
(lambda _ (error 'cover "given unknown coverage output format: ~s" output-format))))
(define (generate-coverage . args)
(for/list ([output-format (in-list (if (list? output-formats)
output-formats
(list output-formats)))])
(apply (hash-ref (get-formats) output-format
(lambda _
(error 'cover "given unknown coverage output format: ~s" output-format)))
args)))
(define passed (apply test-files!
#:submod submods
#:dont-compile exclude-paths

View File

@ -11,8 +11,8 @@ exists). It will then dump the coverage information into a directory, by default
The @exec{raco cover} command accepts the following flags:
@itemize[@item{@Flag{f} or @DFlag{format}
--- Sets the coverage output type. This flag defaults to html.
valid formats are:
--- Sets the coverage output type. Can be included more than once.
This flag defaults to html. Valid formats are:
@itemize[@item{html: Generates one html file per tested file.}]
Other packages may install new formats. See @secref{plugin}}
@item{@Flag{b} or @DFlag{exclude-pkg-basics}