From 98c4dc790c357846450061f25b23b87348eeb709 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Thu, 1 Apr 2021 19:13:08 -0700 Subject: [PATCH] tests: SUITE=all, SUITE=name, SUITE=-name Signed-off-by: Andrea Luzzardi --- tests/test.sh | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/test.sh b/tests/test.sh index b7a4f333..4432ef1d 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -o errexit -o errtrace -o functrace -o nounset -o pipefail -readonly SUITE="${SUITE:-""}" +readonly SUITE="${SUITE:-"all"}" # Point this to your dagger binary readonly DAGGER_BINARY="${DAGGER_BINARY:-$d/../cmd/dagger/dagger}" @@ -29,11 +29,23 @@ d=$(cd "$(dirname "${BASH_SOURCE[0]:-$PWD}")" 2>/dev/null 1>&2 && pwd) test::all(){ local dagger="$1" - [ -z "$SUITE" ] || [ "$SUITE" = "compute" ] && test::compute "$dagger" - [ -z "$SUITE" ] || [ "$SUITE" = "llb" ] && test::llb "$dagger" - [ -z "$SUITE" ] || [ "$SUITE" = "stdlib" ] && test::stdlib "$dagger" - [ -z "$SUITE" ] || [ "$SUITE" = "cli" ] && test::cli "$dagger" - [ -z "$SUITE" ] || [ "$SUITE" = "examples" ] && test::examples "$dagger" + test::suite "compute" && test::compute "$dagger" + test::suite "llb" && test::llb "$dagger" + test::suite "stdlib" && test::stdlib "$dagger" + test::suite "cli" && test::cli "$dagger" + test::suite "examples" && test::examples "$dagger" +} + +test::suite() { + local name="$1" + + { + # if SUITE is "-foo", run everything that's not "foo" + [[ "$SUITE" = -* ]] && [[ "$SUITE" != "-${name}" ]] + } || { + # Run a specific suite, or match all of them if suite is "all" + [ "${SUITE}" = "all" ] || [ "${SUITE}" = "${name}" ] + } || false } case "${1:-all}" in