diff options
author | Lars Wirzenius <liw@liw.fi> | 2023-12-27 10:56:00 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2023-12-27 10:56:00 +0200 |
commit | 1ec398aef43c8b0ce7b01452e41cd82a1e855187 (patch) | |
tree | 0ce698de2e6670599865b080f02f4476471562e4 | |
parent | cd76361bfc89cbf4e3aaea946966ef7c12e3dabb (diff) | |
download | wumpus-hunter-1ec398aef43c8b0ce7b01452e41cd82a1e855187.tar.gz |
feat: write counts as HTML
Signed-off-by: Lars Wirzenius <liw@liw.fi>
-rwxr-xr-x | wumpus-hunter | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/wumpus-hunter b/wumpus-hunter index d255383..ec86f6f 100755 --- a/wumpus-hunter +++ b/wumpus-hunter @@ -14,6 +14,7 @@ TEST_CMD = "timeout 600s cargo test" LOG_FILE = os.path.expanduser("~/log.txt") RUN_LOG_DIR = os.path.expanduser("~") STATS_FILE = os.path.expanduser("~/stats.txt") +COUNTS_FILE = os.path.expanduser("~/counts.txt") def parse_args(): @@ -39,6 +40,12 @@ def parse_args(): help="Write statistics of results to file", required=True, ) + p.add_argument( + "--counts", + default=COUNTS_FILE, + help="Count statistics per commit to file", + required=True, + ) return p.parse_args() @@ -161,6 +168,27 @@ def rename_log(log, dirname, commit): os.rename(log, run_log) +def count(counts, stats): + d = {} + with open(stats) as f: + for line in f: + (commit, result) = line.split() + if commit not in d: + d[commit] = (0, 0) + (succ, fail) = d[commit] + if result == "SUCCESS": + succ += 1 + else: + fail += 1 + d[commit] = (succ, fail) + with open(counts, "w") as f: + f.write("<ol>\n") + for commit in sorted(d.keys()): + (succ, fail) = d[commit] + f.write(f"<li><a href='{commit}/'>{commit}</a> {succ} {fail}</li>\n") + f.write("</oi>\n") + + def main(): args = parse_args() setup_logging(args.log) @@ -177,5 +205,8 @@ def main(): record_failure(args.stats, commit) rename_log(args.log, args.run_log, commit) + if args.counts: + count(args.counts, args.stats) + main() |