summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2023-12-27 10:41:04 +0200
committerLars Wirzenius <liw@liw.fi>2023-12-27 10:41:04 +0200
commit70fddb15d2ddee42030276a7d9771ed5e4676d5a (patch)
tree4c5a44e60fdf15deb8d652fd7425059d76519c7c
parentc2d886b5957fe5199cd8138164b24abace7f26d1 (diff)
downloadwumpus-hunter-70fddb15d2ddee42030276a7d9771ed5e4676d5a.tar.gz
feat: per-run log files
Signed-off-by: Lars Wirzenius <liw@liw.fi>
-rwxr-xr-xwumpus-hunter19
1 files changed, 18 insertions, 1 deletions
diff --git a/wumpus-hunter b/wumpus-hunter
index 492d772..f708d43 100755
--- a/wumpus-hunter
+++ b/wumpus-hunter
@@ -4,6 +4,7 @@ import argparse
import logging
import os
import subprocess
+import time
HEARTWOOD_URL = "https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git"
@@ -11,6 +12,7 @@ HEARTWOOD_REF = "master"
CLONE_DIR = os.path.expanduser("~/src")
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")
@@ -26,6 +28,11 @@ def parse_args():
p.add_argument("--test", default=TEST_CMD, help="Command to run tests")
p.add_argument("--log", default=LOG_FILE, help="Write log file")
p.add_argument(
+ "--run-log",
+ default=RUN_LOG_DIR,
+ help="Write per-run log file to this directory",
+ )
+ p.add_argument(
"--stats", default=STATS_FILE, help="Write statistics of results to file"
)
return p.parse_args()
@@ -141,13 +148,22 @@ def record(filename, commit, result):
f.write(f"{commit} {result}\n")
+def rename_log(log, dirname, commit):
+ commit_dir = os.path.join(dirname, f"log-{commit}")
+ if not os.path.exists(commit_dir):
+ os.mkdir(commit_dir)
+ timestamp = time.strftime("%Y-$%m-%dT%H:%M:%S")
+ run_log = os.path.join(commit_dir, f"log-{timestamp}.txt")
+ os.rename(log, run_log)
+
+
def main():
args = parse_args()
setup_logging(args.log)
+ commit = get_code(args.url, args.ref, args.dir)
logging.debug(f"url: {args.url}")
logging.debug(f"ref: {args.ref}")
logging.debug(f"dir: {args.dir}")
- commit = get_code(args.url, args.ref, args.dir)
try:
build(args.dir)
run_tests(args.dir, args.test)
@@ -155,6 +171,7 @@ def main():
except Exception as e:
logging.error(f"{e}", exc_info=True)
record_failure(args.stats, commit)
+ rename_log(args.log, args.run_log, commit)
main()