mirror of
https://github.com/sstephenson/bats.git
synced 2024-11-17 11:42:33 +01:00
Merge pull request #19 from agent-0028/harschware-tap_skip_test_fix
Transfer bats#142 - This commit corrects the problem of incorrect TAP format for skipped tests
This commit is contained in:
commit
6ce148b9d2
|
@ -257,11 +257,10 @@ bats_exit_trap() {
|
|||
local skipped
|
||||
trap - err exit
|
||||
|
||||
skipped=""
|
||||
if [ -n "$BATS_TEST_SKIPPED" ]; then
|
||||
skipped=" # skip"
|
||||
if [ "1" != "$BATS_TEST_SKIPPED" ]; then
|
||||
skipped+=" ($BATS_TEST_SKIPPED)"
|
||||
skipped+=" $BATS_TEST_SKIPPED"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -272,7 +271,7 @@ bats_exit_trap() {
|
|||
sed -e "s/^/# /" < "$BATS_OUT" >&3
|
||||
status=1
|
||||
else
|
||||
echo "ok ${BATS_TEST_NUMBER}${skipped} ${BATS_TEST_DESCRIPTION}" >&3
|
||||
echo "ok ${BATS_TEST_NUMBER} ${BATS_TEST_DESCRIPTION}${skipped}" >&3
|
||||
status=0
|
||||
fi
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ while IFS= read -r line; do
|
|||
flush
|
||||
;;
|
||||
"ok "* )
|
||||
skip_expr="ok $index # skip (\(([^)]*)\))?"
|
||||
skip_expr="ok $index (.*) # skip ?(([^)]*))?"
|
||||
if [[ "$line" =~ $skip_expr ]]; then
|
||||
let skipped+=1
|
||||
buffer skip "${BASH_REMATCH[2]}"
|
||||
|
|
|
@ -49,7 +49,16 @@ fixtures bats
|
|||
@test "summary passing and skipping tests" {
|
||||
run filter_control_sequences bats -p "$FIXTURE_ROOT/passing_and_skipping.bats"
|
||||
[ $status -eq 0 ]
|
||||
[ "${lines[2]}" = "2 tests, 0 failures, 1 skipped" ]
|
||||
[ "${lines[3]}" = "3 tests, 0 failures, 2 skipped" ]
|
||||
}
|
||||
|
||||
@test "tap passing and skipping tests" {
|
||||
run filter_control_sequences bats --tap "$FIXTURE_ROOT/passing_and_skipping.bats"
|
||||
[ $status -eq 0 ]
|
||||
[ "${lines[0]}" = "1..3" ]
|
||||
[ "${lines[1]}" = "ok 1 a passing test" ]
|
||||
[ "${lines[2]}" = "ok 2 a skipped test with no reason # skip" ]
|
||||
[ "${lines[3]}" = "ok 3 a skipped test with a reason # skip for a really good reason" ]
|
||||
}
|
||||
|
||||
@test "summary passing and failing tests" {
|
||||
|
@ -64,6 +73,15 @@ fixtures bats
|
|||
[ "${lines[5]}" = "3 tests, 1 failure, 1 skipped" ]
|
||||
}
|
||||
|
||||
@test "tap passing, failing and skipping tests" {
|
||||
run filter_control_sequences bats --tap $FIXTURE_ROOT/passing_failing_and_skipping.bats
|
||||
[ $status -eq 0 ]
|
||||
[ "${lines[0]}" = "1..3" ]
|
||||
[ "${lines[1]}" = "ok 1 a passing test" ]
|
||||
[ "${lines[2]}" = "ok 2 a skipping test # skip" ]
|
||||
[ "${lines[3]}" = "not ok 3 a failing test" ]
|
||||
}
|
||||
|
||||
@test "one failing test" {
|
||||
run bats "$FIXTURE_ROOT/failing.bats"
|
||||
[ $status -eq 1 ]
|
||||
|
@ -220,8 +238,8 @@ fixtures bats
|
|||
@test "skipped tests" {
|
||||
run bats "$FIXTURE_ROOT/skipped.bats"
|
||||
[ $status -eq 0 ]
|
||||
[ "${lines[1]}" = "ok 1 # skip a skipped test" ]
|
||||
[ "${lines[2]}" = "ok 2 # skip (a reason) a skipped test with a reason" ]
|
||||
[ "${lines[1]}" = "ok 1 a skipped test # skip" ]
|
||||
[ "${lines[2]}" = "ok 2 a skipped test with a reason # skip a reason" ]
|
||||
}
|
||||
|
||||
@test "extended syntax" {
|
||||
|
|
6
test/fixtures/bats/passing_and_skipping.bats
vendored
6
test/fixtures/bats/passing_and_skipping.bats
vendored
|
@ -2,6 +2,10 @@
|
|||
true
|
||||
}
|
||||
|
||||
@test "a skipping test" {
|
||||
@test "a skipped test with no reason" {
|
||||
skip
|
||||
}
|
||||
|
||||
@test "a skipped test with a reason" {
|
||||
skip "for a really good reason"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user