From ac64e0b18ab70c69d32c541d0433b1ddca2633fb Mon Sep 17 00:00:00 2001 From: Sam Stephenson Date: Wed, 28 Dec 2011 19:14:10 -0600 Subject: [PATCH] Test for failing tests --- libexec/bats-exec | 4 +++- test/bats.bats | 7 +++++++ test/fixtures/one_failing.bats | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/one_failing.bats diff --git a/libexec/bats-exec b/libexec/bats-exec index 25e9a13..1721fb9 100755 --- a/libexec/bats-exec +++ b/libexec/bats-exec @@ -66,10 +66,12 @@ bats_exit_trap() { bats_perform_tests() { echo "1..$#" test_number=1 + status=0 for test_name in "$@"; do - "$0" "$BATS_TEST_FILENAME" "$test_name" "$test_number" || true + "$0" "$BATS_TEST_FILENAME" "$test_name" "$test_number" || status=1 test_number=$(($test_number + 1)) done + exit "$status" } bats_perform_test() { diff --git a/test/bats.bats b/test/bats.bats index 1026158..8b9d42d 100755 --- a/test/bats.bats +++ b/test/bats.bats @@ -26,3 +26,10 @@ FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures" [ ${lines[0]} = "1..1" ] [ ${lines[1]} = "ok 1 a passing test" ] } + +@test "one failing test" { + run bats "$FIXTURE_ROOT/one_failing.bats" + [ $status -eq 1 ] + [ ${lines[0]} = "1..1" ] + [ ${lines[1]} = "not ok 1 a failing test" ] +} diff --git a/test/fixtures/one_failing.bats b/test/fixtures/one_failing.bats new file mode 100644 index 0000000..4e04302 --- /dev/null +++ b/test/fixtures/one_failing.bats @@ -0,0 +1,3 @@ +@test "a failing test" { + false +}