Retrieve the exit code from the test suites
diff --git a/test.sh b/test.sh
index aa829ee..b6ed4b4 100755
--- a/test.sh
+++ b/test.sh
@@ -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
diff --git a/test_program/go-test.sh b/test_program/go-test.sh
index 3c65d15..71293a3 100755
--- a/test_program/go-test.sh
+++ b/test_program/go-test.sh
@@ -5,16 +5,22 @@
 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