1 Basic Usage of Cover
The cover library adds the command raco cover command to run test coverage. For every file it is given it will execute that file and its test submodule (it if exists). It will then dump the coverage information into a directory, by default "coverage". By default the coverage information will be generated as html.
The raco cover command accepts the following flags:
- -f or --format —
Sets the coverage output type. This flag defaults to html. valid formats are: html: Generates one html file per tested file.
Other packages may install new formats. See Creating Custom Output Formats -b or --exclude-pkg-basics —
Equivalent to -n tests -n info.rkt -n scribblings -d or --directory —
Specifies the directory to output coverage information to. defaults to "coverage". -n or --no-output-for-path —
excludes any directories by name from the coverage report. Files in these directories are still run, but are not annotated and omitted from the coverage report. This flag may appear any number of times. -i or --include-extensions —
include the given regular expression in the list of file patterns used when expanding directories, searching for files to cover. -v or --verbose —
enable verbose logging -s or --submod —
run the given submodule instead of the test submodule. -e or --irrelevant-submodules —
Concider the given submodules irrelevant when generating coverage. If not provided defaults to all submodules. Can be included more than once. -c or --collection —
Interprets the arguments as collections whose content should be tested (in the same way as directory content). -p or --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 package scope. -m or --modules —
Interpret arguments as modules. This ignores arguments unless they are files with the extension ".rkt", or ".scrbl". -l or --lib —
Interpret arguments as libraries.
In addition raco cover supports the test-omit-paths and test-command-line-arguments "info.rkt" options like raco test. In addition cover supports cover-omit-paths, which is identical to test-omit-paths, but is specific to cover. The same holds for test-include-paths and cover-include-paths.
1.1 Gotchas
Internally cover uses the logger to transmit coverage. This means that dynamically loading a module with current-logger set to a logger who’s (transitive) parent is not the global logger may cause cover to hang.
Cover runs submodules directly. This means that if the test submodule is not constructed with a module+ or a module* with #f for the language the enclosing module will not be run.
Cover annotates fully expanded programs, and infers what areas of the original program to mark as covered via syntax-location. This means that sometimes, If a macro does not correctly propagate the syntax-location for some syntax object, the coverage information will appear to be incorrect. For example, the for loops will always have their variable binding positions marked as uncovered, unless the for clause binds only one variable and uses one of the special sequence forms like in-list. Another common instance of this is that provides in typed/racket.