mirror of
https://gitlab.com/manzerbredes/esds.git
synced 2025-04-09 22:56:53 +00:00
Add python version of run.sh
This commit is contained in:
parent
5590a909d9
commit
2b2cb09145
1 changed files with 38 additions and 0 deletions
38
tests/run.py
Executable file
38
tests/run.py
Executable file
|
@ -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)
|
Loading…
Add table
Reference in a new issue