diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2022-09-01 10:24:55 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2022-09-01 10:24:55 +0200 |
| commit | 2b2cb091459f050f94c966a8e49fa70d8ccde395 (patch) | |
| tree | 9da957b1cd875f888ab2cd512803814302dd644c /tests | |
| parent | 5590a909d99c779e79f9617f494f0dc645656c36 (diff) | |
Add python version of run.sh
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/run.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/run.py b/tests/run.py new file mode 100755 index 0000000..cb5d88d --- /dev/null +++ b/tests/run.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +import os, subprocess + +teststimeout=20 # Max duration of a test +testspath = os.path.dirname(os.path.realpath(__file__)) + +for file in os.listdir(testspath): + testpath=os.path.join(testspath,file) + if os.path.isdir(testpath): + simulatorpath=os.path.join(testpath,"simulator.py") + outpath=os.path.join(testpath,"out") + print("- %-50s%s " % (file,"=>"),end='') + try: + out=subprocess.check_output(simulatorpath, stderr=subprocess.STDOUT,timeout=teststimeout).decode("utf-8") + outexpected=open(outpath).read() + if outexpected != out: + print("failed :(") + print("------------- Expected -------------") + print(outexpected,end="") + print("------------- Got -------------") + print(out,end="") + else: + print("passed") + except subprocess.TimeoutExpired as err: + print("failed :(") + print("------------- Test timeout (should not exceed "+str(teststimeout)+"s) -------------") + print(err.output.decode("utf-8"),end="") + exit(1) + except subprocess.CalledProcessError as err: + print("failed :(") + print("------------- Non test has a non-zero exit code -------------") + print(err.output.decode("utf-8"),end="") + exit(2) + except Exception as err: + print("failed :(") + print("Reason: "+str(err)) + exit(3) |
