mirror of
https://github.com/sstephenson/bats.git
synced 2024-11-17 03:32:27 +01:00
Invoke bats
with multiple files to run an ad-hoc suite
This commit is contained in:
parent
bc72b85871
commit
672f6e4be2
27
libexec/bats
27
libexec/bats
|
@ -46,19 +46,28 @@ if [ "$1" = "-c" ]; then
|
|||
shift
|
||||
fi
|
||||
|
||||
filename="$1"
|
||||
if [ -z "$filename" ]; then
|
||||
if [ -z "$1" ]; then
|
||||
{ version
|
||||
echo "usage: $0 [-c] <filename>"
|
||||
echo "usage: $0 [-c] <filename> [<filename> ...]"
|
||||
} >&2
|
||||
exit 1
|
||||
else
|
||||
shift
|
||||
fi
|
||||
|
||||
if [ -d "$filename" ]; then
|
||||
shopt -s nullglob
|
||||
exec bats-exec-suite $count_only "$(expand_path "$filename")"/*.bats
|
||||
filenames=()
|
||||
for filename in "$@"; do
|
||||
if [ -d "$filename" ]; then
|
||||
shopt -s nullglob
|
||||
for suite_filename in "$(expand_path "$filename")"/*.bats; do
|
||||
filenames["${#filenames[@]}"]="$suite_filename"
|
||||
done
|
||||
shopt -u nullglob
|
||||
else
|
||||
filenames["${#filenames[@]}"]="$(expand_path "$filename")"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "${#filenames[@]}" -eq 1 ]; then
|
||||
exec bats-exec-test $count_only "${filenames[0]}"
|
||||
else
|
||||
exec bats-exec-test $count_only "$(expand_path "$filename")" "$@"
|
||||
exec bats-exec-suite $count_only "${filenames[@]}"
|
||||
fi
|
||||
|
|
9
test/suite.bats
Normal file → Executable file
9
test/suite.bats
Normal file → Executable file
|
@ -41,3 +41,12 @@ fixtures suite
|
|||
[ ${lines[0]} = "1..3" ]
|
||||
echo "$output" | grep "^not ok . quasi-truth"
|
||||
}
|
||||
|
||||
@test "running an ad-hoc suite by specifying multiple test files" {
|
||||
run bats "$FIXTURE_ROOT/multiple/a.bats" "$FIXTURE_ROOT/multiple/b.bats"
|
||||
[ $status -eq 0 ]
|
||||
[ ${lines[0]} = "1..3" ]
|
||||
echo "$output" | grep "^ok . truth"
|
||||
echo "$output" | grep "^ok . more truth"
|
||||
echo "$output" | grep "^ok . quasi-truth"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user