-
-
Notifications
You must be signed in to change notification settings - Fork 459
Description
Is your feature request related to a problem? Please describe.
See bazel-contrib/rules_python#2762 for some context.
Due to the way Bazel and rules_python is set up, it can happen that coverage run is invoked so that it generates an empty .coverage database. In particular, Bazel can be instructed to only instrument certain files/directories for coverage; if these directories don't contain any Python files the coverage database will be empty. In that case, coverage lcov unconditionally fails with a NoDataError exception. This case is somewhat difficult to detect in advance.
Describe the solution you'd like
A command-line option to coverage lcov to ignore an empty database. When the option is given, coverage lcov would write an empty LCOV file and exit successfully.
Describe alternatives you've considered
- Somehow detect the case in advance: this seems quite difficult because the coverage driver script in rules_python would need to detect whether there are any Python source files in the to-be-covered directories, effectively duplicating the work of coverage.py
- Detect the case after the
coverage runcommand: Would require finding and parsing the.coveragedatabase - Ignoring the exit status of
coverage lcov: would suppress detection of any other errors
Additional context
bazel-contrib/rules_python#2762