diff --git a/info.rkt b/info.rkt index 6f1776b..6bfd2cd 100644 --- a/info.rkt +++ b/info.rkt @@ -2,7 +2,7 @@ (define name "cover") (define collection "cover") (define deps '("base" "errortrace-lib" "rackunit-lib" - "syntax-color-lib")) + "syntax-color-lib" "compiler-lib")) (define build-deps '("racket-doc" "scribble-lib" "typed-racket-doc")) diff --git a/raco.rkt b/raco.rkt index fcebfb5..0f6d47b 100644 --- a/raco.rkt +++ b/raco.rkt @@ -6,7 +6,10 @@ racket/function "main.rkt" (only-in "private/contracts.rkt" coverage-gen/c) - "private/shared.rkt") + "private/shared.rkt" + (only-in (submod compiler/commands/test paths) collection-paths) + pkg/lib) + (module+ test (require rackunit racket/runtime-path racket/set)) @@ -18,6 +21,7 @@ (define exclude-paths '()) (define include-exts '()) (define submod 'test) + (define expansion-type 'dir) (define args (command-line @@ -45,9 +49,20 @@ [("-s" "--submodule") s "Run the given submodule instead of the test submodule" (set! submod (string->symbol s))] + #:once-any + [("-c" "--collection") "Interprets the arguments as collections whose content should be tested (in the same way as directory content)." + (set! expansion-type 'collection)] + [("-p" "--package") "Interprets the arguments as packages whose contents should be tested (in the same way as directory content)." + (set! expansion-type 'package)] #:args (file . files) (cons file files))) - (define files (expand-directories args include-exts)) + (define path-expand + (case expansion-type + [(dir) expand-directories] + [(collection) (lambda (a b) (expand-directories (flatten (map collection-paths a)) b))] + [(package) (lambda (a b) + (expand-directories (map pkg-directory a) b))])) + (define files (path-expand args include-exts)) (define generate-coverage (hash-ref (get-formats) output-format (lambda _ (error 'cover "given unknown coverage output format: ~s" output-format)))) diff --git a/scribblings/basics.scrbl b/scribblings/basics.scrbl index 3c6f1c2..49f90c2 100644 --- a/scribblings/basics.scrbl +++ b/scribblings/basics.scrbl @@ -38,4 +38,11 @@ The @exec{raco cover} command accepts the following flags: --- enable verbose logging} @item{@Flag{s} or @DFlag{submod} --- run the given submodule instead of the test submodule.} - ] + @item{@Flag{c} or @DFlag{collection} + --- Interprets the arguments as collections whose content should be + tested (in the same way as directory content).} + @item{@Flag{p} or @DFlag{package} + --- Interprets the arguments as packages whose contents should be tested + (in the same way as directory content). All package scopes are searched + for the first, most specific + @tech[#:doc '(lib "pkg/scribblings/pkg.scrbl")]{package scope}.}]