HelloWorld/precommit-hooks/coverage.bash

23 lines
560 B
Bash

#!/bin/bash
#
# Find that we have tests for each file.
retcode=0
for language in `ls -1 ./HelloWorld.* | cut -f 3 -d '.'`; do
# Ensure there's a test file.
if [ ! -f tests/test_"${language}".py ]; then
echo "${language^} is missing a test file."
retcode=1
else
# Ensure that each test is defined.
if ! grep "^def test_${language}():$" tests/test_"${language}".py &>/dev/null; then
echo "${language^} doesn't have the right test definition."
retcode=1
fi
fi
done
exit $retcode