-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from Infleqtion/modular-coverage
Improved modular coverage
- Loading branch information
Showing
2 changed files
with
2 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,8 @@ | ||
#!/usr/bin/env python3 | ||
import sys | ||
from collections.abc import Iterable | ||
|
||
import checks_superstaq | ||
import pytest_ | ||
|
||
|
||
def run_modular(exclude: str | Iterable[str] = ("*_test.py",) + pytest_.EXCLUDE) -> int: | ||
"""Check that each file is covered by its own data file.""" | ||
|
||
# start by identifying files that should be covered | ||
tracked_files = checks_superstaq.check_utils.get_tracked_files("*.py") | ||
coverage_files = checks_superstaq.check_utils.exclude_files(tracked_files, exclude) | ||
|
||
# run checks on individual files | ||
exit_codes = {} | ||
for file in coverage_files: | ||
exit_codes[file] = checks_superstaq.coverage_.run(file) | ||
|
||
# print warnings for files that are not covered | ||
for file, exit_code in exit_codes.items(): | ||
if exit_code: | ||
checks_superstaq.check_utils.warning(f"Coverage failed for {file}.") | ||
|
||
return sum(exit_codes.values()) | ||
|
||
|
||
if __name__ == "__main__": | ||
if sys.argv[1:]: | ||
# check coverage for the provided arguments | ||
exit(checks_superstaq.coverage_.run(*sys.argv[1:])) | ||
|
||
# check for modular coverage | ||
exit(run_modular()) | ||
exit(checks_superstaq.coverage_.run(*sys.argv[1:], "--modular", exclude=pytest_.EXCLUDE)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters