diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2021-10-31 07:42:56 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2021-10-31 07:42:56 -0400 |
commit | 1092a800d77f49a2b53e9f386a16f333550d3a7b (patch) | |
tree | b20ef3856039ffc0595274aaf69497606da64406 /lab/goals.py | |
parent | 56713f234c0a607947f201f1b4b2b972776251b5 (diff) | |
download | python-coveragepy-git-nedbat/goals-poc.tar.gz |
wip: proof-of-concept for coverage-goalsnedbat/goals-poc
Diffstat (limited to 'lab/goals.py')
-rw-r--r-- | lab/goals.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lab/goals.py b/lab/goals.py new file mode 100644 index 00000000..3839ecc0 --- /dev/null +++ b/lab/goals.py @@ -0,0 +1,36 @@ +import json +import sys + +from wcmatch import fnmatch as wcfnmatch + +from coverage.results import Numbers + + +def get_data(): + with open("coverage.json") as j: + return json.load(j) + +def select_files(files, pat): + flags = wcfnmatch.NEGATE + selected = [f for f in files if wcfnmatch.fnmatch(f, pat, flags=flags)] + return selected + +data = get_data() +pat = sys.argv[1:] +all_files = list(data["files"].keys()) +selected = select_files(all_files, pat) + +total = Numbers(precision=3) +for sel in selected: + sel_summ = data["files"][sel]["summary"] + total += Numbers( + n_statements=sel_summ["num_statements"], + n_excluded=sel_summ["excluded_lines"], + n_missing=sel_summ["missing_lines"], + n_branches=sel_summ["num_branches"], + n_partial_branches=sel_summ["num_partial_branches"], + n_missing_branches=sel_summ["missing_branches"], + ) + +print(total.pc_covered) +print(total.pc_covered_str) |