mirror of
https://gitlab.com/manzerbredes/esds.git
synced 2025-04-07 02:26:28 +02:00
Switch to run.py
This commit is contained in:
parent
2b2cb09145
commit
47e7d3a9da
3 changed files with 16 additions and 57 deletions
|
@ -5,7 +5,7 @@ archlinux:
|
||||||
- pip install build
|
- pip install build
|
||||||
- pip install .
|
- pip install .
|
||||||
script:
|
script:
|
||||||
- ./tests/run.sh
|
- ./tests/run.py
|
||||||
|
|
||||||
debian:
|
debian:
|
||||||
image: "debian:latest"
|
image: "debian:latest"
|
||||||
|
@ -15,5 +15,5 @@ debian:
|
||||||
- pip install build
|
- pip install build
|
||||||
- pip install .
|
- pip install .
|
||||||
script:
|
script:
|
||||||
- ./tests/run.sh
|
- ./tests/run.py
|
||||||
|
|
||||||
|
|
26
tests/run.py
26
tests/run.py
|
@ -2,29 +2,31 @@
|
||||||
|
|
||||||
import os, subprocess
|
import os, subprocess
|
||||||
|
|
||||||
teststimeout=20 # Max duration of a test
|
##### Setup Variables
|
||||||
testspath = os.path.dirname(os.path.realpath(__file__))
|
tests_timeout=20 # Max duration of a test
|
||||||
|
tests_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
for file in os.listdir(testspath):
|
##### Run All Tests
|
||||||
testpath=os.path.join(testspath,file)
|
for file in os.listdir(tests_path):
|
||||||
if os.path.isdir(testpath):
|
current_test_path=os.path.join(tests_path,file)
|
||||||
simulatorpath=os.path.join(testpath,"simulator.py")
|
if os.path.isdir(current_test_path):
|
||||||
outpath=os.path.join(testpath,"out")
|
simulator_path=os.path.join(current_test_path,"simulator.py")
|
||||||
|
out_path=os.path.join(current_test_path,"out")
|
||||||
print("- %-50s%s " % (file,"=>"),end='')
|
print("- %-50s%s " % (file,"=>"),end='')
|
||||||
try:
|
try:
|
||||||
out=subprocess.check_output(simulatorpath, stderr=subprocess.STDOUT,timeout=teststimeout).decode("utf-8")
|
out=subprocess.check_output(simulator_path, stderr=subprocess.STDOUT,timeout=tests_timeout).decode("utf-8")
|
||||||
outexpected=open(outpath).read()
|
out_expected=open(out_path).read()
|
||||||
if outexpected != out:
|
if out_expected != out:
|
||||||
print("failed :(")
|
print("failed :(")
|
||||||
print("------------- Expected -------------")
|
print("------------- Expected -------------")
|
||||||
print(outexpected,end="")
|
print(out_expected,end="")
|
||||||
print("------------- Got -------------")
|
print("------------- Got -------------")
|
||||||
print(out,end="")
|
print(out,end="")
|
||||||
else:
|
else:
|
||||||
print("passed")
|
print("passed")
|
||||||
except subprocess.TimeoutExpired as err:
|
except subprocess.TimeoutExpired as err:
|
||||||
print("failed :(")
|
print("failed :(")
|
||||||
print("------------- Test timeout (should not exceed "+str(teststimeout)+"s) -------------")
|
print("------------- Test timeout (should not exceed "+str(tests_timeout)+"s) -------------")
|
||||||
print(err.output.decode("utf-8"),end="")
|
print(err.output.decode("utf-8"),end="")
|
||||||
exit(1)
|
exit(1)
|
||||||
except subprocess.CalledProcessError as err:
|
except subprocess.CalledProcessError as err:
|
||||||
|
|
43
tests/run.sh
43
tests/run.sh
|
@ -1,43 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
wai=$(dirname $(readlink -f "$0")) # Current script directory
|
|
||||||
tests=$(ls -d ${wai}/*/) # Find tests
|
|
||||||
out=$(mktemp)
|
|
||||||
test_timeout=20
|
|
||||||
abort=1
|
|
||||||
|
|
||||||
for test in ${tests}
|
|
||||||
do
|
|
||||||
printf "%-50s%s %s" "- $(basename $test)" "=>"
|
|
||||||
cd $test
|
|
||||||
timeout $test_timeout ./simulator.py &> "$out"
|
|
||||||
|
|
||||||
# Ensure timeout
|
|
||||||
if [ $? -eq 124 ]
|
|
||||||
then
|
|
||||||
echo "failed :("
|
|
||||||
echo "------------- Test timeout (should not exceed ${test_timeout}s) -------------"
|
|
||||||
cat "$out";
|
|
||||||
rm "$out"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Ensure test output
|
|
||||||
if [ "$(base64 $out)" = "$(base64 ./out)" ]
|
|
||||||
then
|
|
||||||
echo "passed"
|
|
||||||
else
|
|
||||||
echo "failed :("
|
|
||||||
echo "------------- Expected -------------"
|
|
||||||
cat out
|
|
||||||
echo "------------- Got -------------"
|
|
||||||
cat "$out";
|
|
||||||
rm "$out"
|
|
||||||
[ $abort -eq 1 ] && exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Prepare for next test
|
|
||||||
cd - &>/dev/null
|
|
||||||
done
|
|
||||||
|
|
||||||
rm "$out"
|
|
Loading…
Add table
Reference in a new issue