mirror of
https://github.com/cosinekitty/astronomy.git
synced 2026-01-01 20:20:15 -05:00
I refactored the unit tests for all the demo programs to follow a different pattern that makes it simpler to add more demo tests in the future. The main thing is that correct output and generated output are now in separate directories `correct` and `test`. I have moved the test scripts from `test/test` to `./demotest` in all the langauge demo directories. This makes it simpler to clean up any stale generated files before each test run by `rm -f test/*.txt`. I stumbled across this while making the Java demo tests, and it was a better solution, so now all the other languages are consistent with the Java demo tests. In the C demo tests, I also decided to compile all the binary executables into a subdirectory `bin` that can be cleaned out before each run, to make sure there are no stale executables from an earlier run.
32 lines
821 B
Bash
Executable File
32 lines
821 B
Bash
Executable File
#!/bin/bash
|
|
|
|
if [[ "$1" == "debug" ]]; then
|
|
BUILDOPT='-g -Og'
|
|
else
|
|
BUILDOPT='-O3'
|
|
fi
|
|
|
|
echo "run_worldmap: building C++ code"
|
|
|
|
rm -f bin/worldmap
|
|
mkdir -p bin
|
|
g++ -Wall -Werror -x c++ -std=c++11 -o bin/worldmap $BUILDOPT \
|
|
-I./raytrace -I../../source/c \
|
|
worldmap.cpp astro_demo_common.c ../../source/c/astronomy.c raytrace/lodepng.cpp \
|
|
|| exit $?
|
|
|
|
echo "run_worldmap: creating image"
|
|
|
|
rm -f sun_moon_map.png test/worldmap.txt
|
|
time bin/worldmap sun_moon_map.png 2022-04-09T16:05:35Z > test/worldmap.txt || exit $?
|
|
more test/worldmap.txt || exit $?
|
|
if ! diff {correct,test}/worldmap.txt; then
|
|
echo "run_worldmap: FAIL - incorrect zenith location output."
|
|
exit 1
|
|
fi
|
|
|
|
ls -l sun_moon_map.png || exit $?
|
|
../../generate/checksum.py sha256 worldmap.sha256 || exit $?
|
|
echo "run_worldmap: PASS"
|
|
exit 0
|