Making sure unit tests work #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Unit Tests | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
format: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install valgrind | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y valgrind | |
- name: Compile Tests | |
run: | | |
mkdir test/bin | |
make test | |
- name: Run Tests | |
run: | | |
error=0 | |
for test in test/bin/*; do | |
failure=$(valgrind --leak-check=full --error-exitcode=1 --show-leak-kinds=all --errors-for-leak-kinds=all $test 2>&1) | |
if [ $? -ne 0 ]; then | |
error=1 | |
echo $failure | |
echo "Test $test failed" | |
else | |
echo "Test $test passed" | |
fi | |
done | |
exit $error |