mirror of
https://github.com/sstephenson/bats.git
synced 2024-11-17 03:32:27 +01:00
commit
d628bd7251
|
@ -11,6 +11,7 @@ if [[ "$header" =~ $header_pattern ]]; then
|
||||||
count="${header:3}"
|
count="${header:3}"
|
||||||
index=0
|
index=0
|
||||||
failures=0
|
failures=0
|
||||||
|
skipped=0
|
||||||
name=""
|
name=""
|
||||||
count_column_width=$(( ${#count} * 2 + 2 ))
|
count_column_width=$(( ${#count} * 2 + 2 ))
|
||||||
else
|
else
|
||||||
|
@ -64,9 +65,15 @@ log() {
|
||||||
}
|
}
|
||||||
|
|
||||||
summary() {
|
summary() {
|
||||||
printf "\n%d test%s, %d failure%s\n" \
|
printf "\n%d test%s" "$count" "$(plural "$count")"
|
||||||
"$count" "$(plural "$count")" \
|
|
||||||
"$failures" "$(plural "$failures")"
|
printf ", %d failure%s" "$failures" "$(plural "$failures")"
|
||||||
|
|
||||||
|
if [ "$skipped" -gt 0 ]; then
|
||||||
|
printf ", %d skipped" "$skipped"
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
printf_with_truncation() {
|
printf_with_truncation() {
|
||||||
|
@ -139,6 +146,7 @@ while IFS= read -r line; do
|
||||||
"ok "* )
|
"ok "* )
|
||||||
skip_expr="ok $index # skip (\(([^)]*)\))?"
|
skip_expr="ok $index # skip (\(([^)]*)\))?"
|
||||||
if [[ "$line" =~ $skip_expr ]]; then
|
if [[ "$line" =~ $skip_expr ]]; then
|
||||||
|
let skipped+=1
|
||||||
buffer skip "${BASH_REMATCH[2]}"
|
buffer skip "${BASH_REMATCH[2]}"
|
||||||
else
|
else
|
||||||
buffer pass
|
buffer pass
|
||||||
|
|
|
@ -40,6 +40,30 @@ fixtures bats
|
||||||
[ ${lines[1]} = "ok 1 a passing test" ]
|
[ ${lines[1]} = "ok 1 a passing test" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "summary passing tests" {
|
||||||
|
run filter_control_sequences bats -p $FIXTURE_ROOT/passing.bats
|
||||||
|
[ $status -eq 0 ]
|
||||||
|
[ "${lines[1]}" = "1 test, 0 failures" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@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" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "summary passing and failing tests" {
|
||||||
|
run filter_control_sequences bats -p $FIXTURE_ROOT/failing_and_passing.bats
|
||||||
|
[ $status -eq 0 ]
|
||||||
|
[ "${lines[4]}" = "2 tests, 1 failure" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "summary passing, failing and skipping tests" {
|
||||||
|
run filter_control_sequences bats -p $FIXTURE_ROOT/passing_failing_and_skipping.bats
|
||||||
|
[ $status -eq 0 ]
|
||||||
|
[ "${lines[5]}" = "3 tests, 1 failure, 1 skipped" ]
|
||||||
|
}
|
||||||
|
|
||||||
@test "one failing test" {
|
@test "one failing test" {
|
||||||
run bats "$FIXTURE_ROOT/failing.bats"
|
run bats "$FIXTURE_ROOT/failing.bats"
|
||||||
[ $status -eq 1 ]
|
[ $status -eq 1 ]
|
||||||
|
|
7
test/fixtures/bats/passing_and_failing.bats
vendored
Normal file
7
test/fixtures/bats/passing_and_failing.bats
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
@test "a passing test" {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a failing test" {
|
||||||
|
false
|
||||||
|
}
|
7
test/fixtures/bats/passing_and_skipping.bats
vendored
Normal file
7
test/fixtures/bats/passing_and_skipping.bats
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
@test "a passing test" {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a skipping test" {
|
||||||
|
skip
|
||||||
|
}
|
11
test/fixtures/bats/passing_failing_and_skipping.bats
vendored
Normal file
11
test/fixtures/bats/passing_failing_and_skipping.bats
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
@test "a passing test" {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a skipping test" {
|
||||||
|
skip
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "a failing test" {
|
||||||
|
false
|
||||||
|
}
|
|
@ -7,6 +7,10 @@ setup() {
|
||||||
export TMP="$BATS_TEST_DIRNAME/tmp"
|
export TMP="$BATS_TEST_DIRNAME/tmp"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filter_control_sequences() {
|
||||||
|
"$@" | sed $'s,\x1b\\[[0-9;]*[a-zA-Z],,g'
|
||||||
|
}
|
||||||
|
|
||||||
teardown() {
|
teardown() {
|
||||||
[ -d "$TMP" ] && rm -f "$TMP"/*
|
[ -d "$TMP" ] && rm -f "$TMP"/*
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user