mirror of
https://github.com/sstephenson/bats.git
synced 2024-11-17 11:42:33 +01:00
Add skip directive.
This commit is contained in:
parent
bc72b85871
commit
d05dc2d8c9
|
@ -92,9 +92,12 @@ bats_exit_trap() {
|
||||||
echo "# $BATS_TEST_FILENAME:$BATS_LINE_NUMBER" >&3
|
echo "# $BATS_TEST_FILENAME:$BATS_LINE_NUMBER" >&3
|
||||||
sed -e "s/^/# /" < "$BATS_OUT" >&3
|
sed -e "s/^/# /" < "$BATS_OUT" >&3
|
||||||
status=1
|
status=1
|
||||||
else
|
elif [ -z "$BATS_TEST_SKIPPED" ]; then
|
||||||
echo "ok $BATS_TEST_NUMBER $BATS_TEST_DESCRIPTION" >&3
|
echo "ok $BATS_TEST_NUMBER $BATS_TEST_DESCRIPTION" >&3
|
||||||
status=0
|
status=0
|
||||||
|
else
|
||||||
|
echo "ok $BATS_TEST_NUMBER # skip $BATS_TEST_DESCRIPTION" >&3
|
||||||
|
status=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f "$BATS_OUT"
|
rm -f "$BATS_OUT"
|
||||||
|
@ -122,7 +125,16 @@ bats_perform_test() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
BATS_TEST_COMPLETED=""
|
BATS_TEST_COMPLETED=""
|
||||||
|
BATS_TEST_SKIPPED=""
|
||||||
BATS_ERROR_LINE=""
|
BATS_ERROR_LINE=""
|
||||||
|
|
||||||
|
directive="$(expr "$BATS_TEST_NAME" : '\([^_]*\)' || true)"
|
||||||
|
if [ "skip" = "$directive" ]; then
|
||||||
|
BATS_TEST_SKIPPED=1
|
||||||
|
BATS_TEST_COMPLETED=1
|
||||||
|
trap "bats_teardown_trap" exit
|
||||||
|
fi
|
||||||
|
|
||||||
trap "bats_debug_trap \"\$BASH_SOURCE\" \$LINENO" debug
|
trap "bats_debug_trap \"\$BASH_SOURCE\" \$LINENO" debug
|
||||||
trap "bats_error_trap" err
|
trap "bats_error_trap" err
|
||||||
trap "bats_teardown_trap" exit
|
trap "bats_teardown_trap" exit
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
encode_name() {
|
encode_name() {
|
||||||
local name="$1"
|
local result="$1_"
|
||||||
local result="test_"
|
local name="$2"
|
||||||
|
|
||||||
if [[ ! "$name" =~ [^[:alnum:]\ _-] ]]; then
|
if [[ ! "$name" =~ [^[:alnum:]\ _-] ]]; then
|
||||||
name="${name//_/-5f}"
|
name="${name//_/-5f}"
|
||||||
|
@ -34,13 +34,14 @@ index=0
|
||||||
|
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
index=$(($index + 1))
|
index=$(($index + 1))
|
||||||
quoted_name="$(expr "$line" : ' *@test *\([^ ].*\) *{ *$' || true)"
|
directive="$(expr "$line" : ' *@\([test\|skip]*\) *\([^ ].*\) *{ *$' || true)"
|
||||||
|
quoted_name="$(expr "$line" : ' *@[test\|skip]* *\([^ ].*\) *{ *$' || true)"
|
||||||
|
|
||||||
if [ -n "$quoted_name" ]; then
|
if [ -n "$quoted_name" ]; then
|
||||||
name="$(eval echo "$quoted_name")"
|
name="$(eval echo "$quoted_name")"
|
||||||
encoded_name="$(encode_name "$name")"
|
encoded_name="$(encode_name "$directive" "$name")"
|
||||||
tests["${#tests[@]}"]="$encoded_name"
|
|
||||||
echo "${encoded_name}() { bats_test_info ${quoted_name} ${index}"
|
echo "${encoded_name}() { bats_test_info ${quoted_name} ${index}"
|
||||||
|
tests["${#tests[@]}"]="$encoded_name"
|
||||||
else
|
else
|
||||||
printf "%s\n" "$line"
|
printf "%s\n" "$line"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -110,3 +110,8 @@ fixtures bats
|
||||||
run bats "$FIXTURE_ROOT/dos_line.bats"
|
run bats "$FIXTURE_ROOT/dos_line.bats"
|
||||||
[ $status -eq 0 ]
|
[ $status -eq 0 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@skip "A skipped test" {
|
||||||
|
run bats
|
||||||
|
[ $status -eq 0 ]
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user