Retrieve the exit code from the test suites

This commit is contained in:
Thomas Pelletier
2013-12-10 15:28:52 +01:00
parent def5433558
commit 979a055512
2 changed files with 11 additions and 1 deletions
+4
View File
@@ -2,6 +2,10 @@
# Run basic go unit tests
go test -v ./...
result=$?
# Run example-based toml tests
cd test_program && ./go-test.sh
result="$(( result || $? ))"
exit $result
+7 -1
View File
@@ -5,16 +5,22 @@ go get github.com/BurntSushi/toml/toml-test-go # install my parser
go build -o test_program_bin github.com/pelletier/go-toml/test_program
toml_test_wrapper() {
ret=0
if hash toml-test 2>/dev/null; then # test availability in $PATH
toml-test "$@"
ret=$?
else
p="$HOME/gopath/bin/toml-test" # try in Travi's place
if [ -f "$p" ]; then
"$p" "$@"
ret=$?
else
"$GOPATH/bin/toml-test" "$@"
ret=$?
fi
fi
}
toml_test_wrapper ./test_program_bin # run tests on my parser
toml_test_wrapper ./test_program_bin | tee test_out
ret="$([ `tail -n 1 test_out | sed -E 's/^.+([0-9]+) failed$/\1/'` -eq 0 ])"
exit $ret