diff --git a/libexec/bats b/libexec/bats index f51df54..d7a77fa 100755 --- a/libexec/bats +++ b/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] " + echo "usage: $0 [-c] [ ...]" } >&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 diff --git a/test/suite.bats b/test/suite.bats old mode 100644 new mode 100755 index 5d5132f..87f61d5 --- a/test/suite.bats +++ b/test/suite.bats @@ -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" +}