Files
astronomy/generate/unit_test_python
Don Cross 6b0bc73b0b Reworking Python unit tests to be table-driven.
I like what I did to the JavaScript tests, where I no longer
need to update scripts when I add a new unit test.
So I have decided to do the same for the other languages,
starting with Python.
2020-06-03 11:57:30 -04:00

35 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
Fail()
{
echo "ERROR($0): $1"
exit 1
}
[[ "$1" == "" || "$1" == "-v" ]] || Fail "Invalid command line options."
python3 --version || Fail "Cannot print python version"
python3 test.py $1 rotation || Fail "Failed Python rotation tests."
python3 test.py $1 refraction || Fail "Failed Python refraction tests."
python3 test.py $1 time || Fail "Failure reported by test.py (time)"
python3 test.py $1 lunar_apsis || Fail "Failed Python lunar apsis tests."
python3 test.py $1 planet_apsis || Fail "Failed Python planet apsis tests."
python3 test.py $1 magnitude || Fail "Failed Python magnitude tests."
python3 test.py $1 moon || Fail "Failure reported by test.py (moon)"
python3 test.py $1 seasons || Fail "Failed Python seasons test."
python3 test.py $1 moonphase || Fail "Failed Python moon phase test."
python3 test.py $1 riseset || Fail "Failed Python rise/set tests."
python3 test.py $1 constellation || Fail "Failed Python constellation test."
python3 test.py $1 lunar_eclipse || Fail "Failed Python lunar eclipse test."
python3 test.py $1 elongation || Fail "Failed Python elongation tests."
for file in temp/py_longitude_*.txt; do
./generate $1 check ${file} || Fail "Failed verification of file ${file}"
done
echo "$0: Generating Python test output."
time python3 test.py astro_check > temp/py_check.txt || Fail "Failure in Python astro_check"
./generate $1 check temp/py_check.txt || Fail "Verification failure for Python unit test output."
echo "$0: PASS"
exit 0