Reputation: 788
I've got the following Makefile script which calls a python test suite that writes the results to a file called test_results.txt
. Then I display the files and read the last line which has a status that indicates whether all the test cases have been executed or not. Based on that value I echo a statement.
target: test.py
$(PYTHON) test.py
@cat test/test_results.txt
@if [ $(shell sed -e '$$!d' test/test_results.txt) = 0 ]; then\
echo "\nAll tests passed successfully";\
else \
echo "\nNot all the tests were passed";\
fi
When I run it, I get the following error: 0/bin/sh: 1: [: =: unexpected operator
Upvotes: 0
Views: 484
Reputation: 531275
It's much simpler to make test.py
have a non-zero exit status if any test fails. Then your recipe is simply
target: test.py
@if $(PYTHON) test.py; then\
echo "\nAll tests passed successfully";\
else \
echo "\nNot all the tests were passed";\
fi
@cat test/test_results.txt
Upvotes: 2