Add support for unit testing.

This commit is contained in:
Jordan Bancino 2022-08-05 22:20:07 -04:00
parent 2e5d21d309
commit a39b0d9f9a

View file

@ -117,7 +117,27 @@ recipe_format() {
# Execute all the unit tests and report any failures.
recipe_test() {
echo "Unit tests are not implemented yet."
passed=0
failed=0
mkdir -p "build/tests"
for testSrc in $(find tests -name 'Test*.c'); do
testBin=$(basename "$testSrc" .c)
testBin="build/tests/$testBin"
if ! $CC $CFLAGS -I src -o "$testBin" "$testSrc"; then
failed=$((failed + 1))
break;
fi
if ! "$testBin"; then
failed=$((failed + 1))
break;
fi
passed=$((passed + 1))
done
echo "Passed: $passed, failed: $failed"
echo "Total: $((passed + failed))"
}
# Deploy the Telodendria website by copying the required files to