Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

make ts scripts exit non-zero if a test fails

  • Loading branch information...
commit 61b7dc2a7c55681b7f2ec4bc8b36a92cb09ffce3 1 parent 0ef806e
@thinkerbot authored
Showing with 34 additions and 5 deletions.
  1. +2 −5 bin/ts
  2. +32 −0 test/suite
View
7 bin/ts
@@ -323,9 +323,6 @@ assert_match () {
# Run the test files if this script is executed directly. Otherwise, set a
# trap to run the current test suite after the tests have been defined.
if [ "ts" = "$ts_progname" ]
-then
- ts_run_test_files "$@"
- exit $?
-else
- trap "ts_run_test_suite $*" EXIT
+then ts_run_test_files "$@"
+else trap "ts_run_test_suite $*; exit \$?" EXIT
fi
View
32 test/suite
@@ -17,6 +17,10 @@ set -x
export TS_TMP_DIR="$test_dir"
}
+#
+# options test
+#
+
test_ts_h_prints_help () {
out=`ts -h`
assert_match "usage:" "$out"
@@ -45,6 +49,10 @@ F
out
}
+#
+# assertions test
+#
+
test_ts_assertions_pass () {
out=`ts test/assertions/pass 2>&1 | tail -n 1`
assert_match "[0-9]{1,} pass 0 fail" "$out"
@@ -54,3 +62,27 @@ test_ts_assertions_fail () {
out=`ts test/assertions/fail 2>&1 | tail -n 1`
assert_match "0 pass [0-9]{1,} fail" "$out"
}
+
+#
+# exit status test
+#
+
+test_ts_exits_0_for_passing_test () {
+ts test/ts/pass
+assert_status 0 $?
+}
+
+test_ts_script_exits_0_for_passing_test () {
+./test/ts/pass
+assert_status 0 $?
+}
+
+test_ts_exits_1_for_failing_test () {
+ts test/ts/fail
+assert_status 1 $?
+}
+
+test_ts_script_exits_1_for_failing_test () {
+./test/ts/fail
+assert_status 1 $?
+}
Please sign in to comment.
Something went wrong with that request. Please try again.