mirror of
https://github.com/sstephenson/bats.git
synced 2024-11-17 11:42:33 +01:00
Invoke bats
with multiple files to run an ad-hoc suite
This commit is contained in:
parent
bc72b85871
commit
672f6e4be2
23
libexec/bats
23
libexec/bats
|
@ -46,19 +46,28 @@ if [ "$1" = "-c" ]; then
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
|
|
||||||
filename="$1"
|
if [ -z "$1" ]; then
|
||||||
if [ -z "$filename" ]; then
|
|
||||||
{ version
|
{ version
|
||||||
echo "usage: $0 [-c] <filename>"
|
echo "usage: $0 [-c] <filename> [<filename> ...]"
|
||||||
} >&2
|
} >&2
|
||||||
exit 1
|
exit 1
|
||||||
else
|
|
||||||
shift
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
filenames=()
|
||||||
|
for filename in "$@"; do
|
||||||
if [ -d "$filename" ]; then
|
if [ -d "$filename" ]; then
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
exec bats-exec-suite $count_only "$(expand_path "$filename")"/*.bats
|
for suite_filename in "$(expand_path "$filename")"/*.bats; do
|
||||||
|
filenames["${#filenames[@]}"]="$suite_filename"
|
||||||
|
done
|
||||||
|
shopt -u nullglob
|
||||||
else
|
else
|
||||||
exec bats-exec-test $count_only "$(expand_path "$filename")" "$@"
|
filenames["${#filenames[@]}"]="$(expand_path "$filename")"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "${#filenames[@]}" -eq 1 ]; then
|
||||||
|
exec bats-exec-test $count_only "${filenames[0]}"
|
||||||
|
else
|
||||||
|
exec bats-exec-suite $count_only "${filenames[@]}"
|
||||||
fi
|
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" ]
|
[ ${lines[0]} = "1..3" ]
|
||||||
echo "$output" | grep "^not ok . quasi-truth"
|
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