From 64cd769fbeb73ba51cfbe47bef51068266d5f4d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Sat, 16 Jan 2016 14:47:44 +0100 Subject: [PATCH] Allow multiple output formats, by specifying `f` several times on the command-line, e.g. `raco cover -f html -f coveralls file.rkt`. --- cover/cover.rkt | 6 +++--- cover/raco.rkt | 21 +++++++++++++-------- cover/scribblings/basics.scrbl | 4 ++-- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/cover/cover.rkt b/cover/cover.rkt index b768d94..2d6d9da 100644 --- a/cover/cover.rkt +++ b/cover/cover.rkt @@ -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))))) diff --git a/cover/raco.rkt b/cover/raco.rkt index 37984e5..da3b7a7 100644 --- a/cover/raco.rkt +++ b/cover/raco.rkt @@ -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 diff --git a/cover/scribblings/basics.scrbl b/cover/scribblings/basics.scrbl index 8d18acf..9742898 100644 --- a/cover/scribblings/basics.scrbl +++ b/cover/scribblings/basics.scrbl @@ -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}