diff options
author | Lars Wirzenius <liw@liw.fi> | 2023-12-27 08:54:04 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2023-12-27 08:54:04 +0200 |
commit | 955ca58b5cfdd1b84f810cbf5405b412dc5f7dac (patch) | |
tree | 3c5130d7ecefb9460b7b09d217a9c4b0cca23754 | |
parent | 72db607705260ce6cb1ee1c5454f46ff161c343b (diff) | |
download | wumpus-hunter-955ca58b5cfdd1b84f810cbf5405b412dc5f7dac.tar.gz |
feat: separate build step from running tests
Signed-off-by: Lars Wirzenius <liw@liw.fi>
-rwxr-xr-x | wumpus-hunter | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/wumpus-hunter b/wumpus-hunter index 7e7041a..887871a 100755 --- a/wumpus-hunter +++ b/wumpus-hunter @@ -77,11 +77,19 @@ def git(*args, cwd=None): return Exception(f"git {args} failed") +def build(dirname): + logging.info(f"build code in {dirname}") + p = subprocess.run( + ["cargo", "build", "--workspace", "--all-targets"], check=True, cwd=dirname + ) + if p.returncode != 0: + return Exception(f"cargo build failed") + + def run_tests(dirname, cmd): logging.info(f"run tests in {dirname}: {cmd}") p = subprocess.run(["bash", "-c", cmd], check=True, cwd=dirname) - if p.returncode != 0: - return Exception(f"test command failed {cmd}") + return p.returncode == 0 def main(): @@ -89,7 +97,11 @@ def main(): print(args) setup_logging() get_code(args.url, args.ref, args.dir) - run_tests(args.dir, args.test) + build(args.dir) + if run_tests(args.dir, args.test): + print("RESULT: OK") + else: + print("RESULT: TEST-FAIL") main() |