Created
July 2, 2018 14:42
-
-
Save jensens/10c5c2e3f9e059a5d4c1038c7bd3e2e7 to your computer and use it in GitHub Desktop.
Simple percentage report of end of tests output.
This file contains hidden or 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
#!./bin/python | |
""" | |
Simple percentage report of end of tests output. Copy the line from there and pass to script: | |
usage: $./calc_test_percentages.py 9372 tests, 180 failures, 324 errors and 266 skipped in 22 minutes 25.188 seconds | |
output: | |
green : 91.784% | |
failures: 1.921% | |
errors : 3.457% | |
skipped : 2.838% | |
""" | |
import re | |
import sys | |
exp_ints = re.compile(r"\d+") | |
exp_words = re.compile(r"[a-z]+") | |
s = " ".join(sys.argv[1:]) | |
counts = [float(x) for x in exp_ints.findall(s)] | |
words = [x for x in exp_words.findall(s) if x not in ["in", "and"]] | |
nums = dict(zip(words, counts)) | |
nums["seconds"] = nums["minutes"] * 60 + nums["seconds"] | |
del nums["minutes"] | |
failures = 100 * nums["failures"] / nums["tests"] | |
errors = 100 * nums["errors"] / nums["tests"] | |
skipped = 100 * nums["skipped"] / nums["tests"] | |
green = 100 - ( | |
100 * (nums["failures"] + nums["errors"] + nums["skipped"]) / nums["tests"] | |
) | |
report = f"""\ | |
green : {green:2.3f}% | |
failures: {failures:2.3f}% | |
errors : {errors:2.3f}% | |
skipped : {skipped:2.3f}% | |
""" | |
print(report) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment