From b229119a3df0cc22882ec6501369772155765d4a Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Thu, 1 Apr 2021 18:46:08 -0700 Subject: [PATCH 1/2] tests: split integration tests Signed-off-by: Andrea Luzzardi --- .../dependencies/interpolation/main.cue | 0 .../dependencies/simple/main.cue | 0 .../dependencies/unmarshal/main.cue | 0 tests/{ => compute}/ignore/main.cue | 0 .../ignore/testdata/.daggerignore | 0 tests/{ => compute}/ignore/testdata/a.txt | 0 tests/{ => compute}/ignore/testdata/b.txt | 0 .../{ => compute}/ignore/testdata/foo/bar.txt | 0 .../ignore/testdata/foo/cow.json | 0 .../react/inputs.yaml} | 0 tests/test-cli.sh | 82 ++++ tests/test-compute.sh | 71 ++++ tests/test-examples.sh | 12 + tests/test-llb.sh | 187 +++++++++ tests/test-stdlib.sh | 20 + tests/test.sh | 367 ++---------------- 16 files changed, 394 insertions(+), 345 deletions(-) rename tests/{ => compute}/dependencies/interpolation/main.cue (100%) rename tests/{ => compute}/dependencies/simple/main.cue (100%) rename tests/{ => compute}/dependencies/unmarshal/main.cue (100%) rename tests/{ => compute}/ignore/main.cue (100%) rename tests/{ => compute}/ignore/testdata/.daggerignore (100%) rename tests/{ => compute}/ignore/testdata/a.txt (100%) rename tests/{ => compute}/ignore/testdata/b.txt (100%) rename tests/{ => compute}/ignore/testdata/foo/bar.txt (100%) rename tests/{ => compute}/ignore/testdata/foo/cow.json (100%) rename tests/{react-example-inputs.yaml => examples/react/inputs.yaml} (100%) create mode 100644 tests/test-cli.sh create mode 100644 tests/test-compute.sh create mode 100644 tests/test-examples.sh create mode 100644 tests/test-llb.sh create mode 100644 tests/test-stdlib.sh diff --git a/tests/dependencies/interpolation/main.cue b/tests/compute/dependencies/interpolation/main.cue similarity index 100% rename from tests/dependencies/interpolation/main.cue rename to tests/compute/dependencies/interpolation/main.cue diff --git a/tests/dependencies/simple/main.cue b/tests/compute/dependencies/simple/main.cue similarity index 100% rename from tests/dependencies/simple/main.cue rename to tests/compute/dependencies/simple/main.cue diff --git a/tests/dependencies/unmarshal/main.cue b/tests/compute/dependencies/unmarshal/main.cue similarity index 100% rename from tests/dependencies/unmarshal/main.cue rename to tests/compute/dependencies/unmarshal/main.cue diff --git a/tests/ignore/main.cue b/tests/compute/ignore/main.cue similarity index 100% rename from tests/ignore/main.cue rename to tests/compute/ignore/main.cue diff --git a/tests/ignore/testdata/.daggerignore b/tests/compute/ignore/testdata/.daggerignore similarity index 100% rename from tests/ignore/testdata/.daggerignore rename to tests/compute/ignore/testdata/.daggerignore diff --git a/tests/ignore/testdata/a.txt b/tests/compute/ignore/testdata/a.txt similarity index 100% rename from tests/ignore/testdata/a.txt rename to tests/compute/ignore/testdata/a.txt diff --git a/tests/ignore/testdata/b.txt b/tests/compute/ignore/testdata/b.txt similarity index 100% rename from tests/ignore/testdata/b.txt rename to tests/compute/ignore/testdata/b.txt diff --git a/tests/ignore/testdata/foo/bar.txt b/tests/compute/ignore/testdata/foo/bar.txt similarity index 100% rename from tests/ignore/testdata/foo/bar.txt rename to tests/compute/ignore/testdata/foo/bar.txt diff --git a/tests/ignore/testdata/foo/cow.json b/tests/compute/ignore/testdata/foo/cow.json similarity index 100% rename from tests/ignore/testdata/foo/cow.json rename to tests/compute/ignore/testdata/foo/cow.json diff --git a/tests/react-example-inputs.yaml b/tests/examples/react/inputs.yaml similarity index 100% rename from tests/react-example-inputs.yaml rename to tests/examples/react/inputs.yaml diff --git a/tests/test-cli.sh b/tests/test-cli.sh new file mode 100644 index 00000000..f918fe0f --- /dev/null +++ b/tests/test-cli.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash +set -o errexit -o errtrace -o functrace -o nounset -o pipefail + +# Test Directory +d=$(cd "$(dirname "${BASH_SOURCE[0]:-$PWD}")" 2>/dev/null 1>&2 && pwd) + +test::cli() { + local dagger="$1" + + test::cli::list "$dagger" + test::cli::newdir "$dagger" + test::cli::query "$dagger" +} + +test::cli::list() { + local dagger="$1" + + # Create temporary store + local DAGGER_STORE + DAGGER_STORE="$(mktemp -d -t dagger-store-XXXXXX)" + export DAGGER_STORE + + test::one "CLI: list: no deployments" --stdout="" \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" list + + test::one "CLI: list: create deployment" \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/simple simple + + test::one "CLI: list: with deployments" --stdout="simple" \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" list +} + +test::cli::newdir() { + local dagger="$1" + + # Create temporary store + local DAGGER_STORE + DAGGER_STORE="$(mktemp -d -t dagger-store-XXXXXX)" + export DAGGER_STORE + + test::one "CLI: new: --plan-dir" \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/simple simple + + test::one "CLI: new: duplicate name" --exit=1 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/simple simple + + test::one "CLI: new: verify plan can be upped" \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" up -d "simple" + + test::one "CLI: new: verify we have the right plan" --stdout='{ + foo: "value" + bar: "another value" +}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple" -c +} + +test::cli::query() { + local dagger="$1" + + # Create temporary store + local DAGGER_STORE + DAGGER_STORE="$(mktemp -d -t dagger-store-XXXXXX)" + export DAGGER_STORE + + test::one "CLI: query: initialize simple" \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/simple simple + + test::one "CLI: query: concrete" --stdout='{ + foo: "value" + bar: "another value" +}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple" -c + + test::one "CLI: query: target" --stdout='"value"' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple" foo + + test::one "CLI: query: initialize nonconcrete" \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/nonconcrete nonconcrete + + test::one "CLI: query: non concrete" --exit=1 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "nonconcrete" -c +} diff --git a/tests/test-compute.sh b/tests/test-compute.sh new file mode 100644 index 00000000..324d9a64 --- /dev/null +++ b/tests/test-compute.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +set -o errexit -o errtrace -o functrace -o nounset -o pipefail + +# Test Directory +d=$(cd "$(dirname "${BASH_SOURCE[0]:-$PWD}")" 2>/dev/null 1>&2 && pwd) + +test::compute(){ + local dagger="$1" + + test::compute::simple "$dagger" + test::compute::dependencies "$dagger" + test::compute::input "$dagger" + test::compute::daggerignore "$dagger" +} + +test::compute::simple(){ + local dagger="$1" + + # Compute: invalid syntax + test::one "Compute: invalid string should fail" --exit=1 --stdout= \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/invalid/string + test::one "Compute: invalid bool should fail" --exit=1 --stdout= \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/invalid/bool + test::one "Compute: invalid int should fail" --exit=1 --stdout= \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/invalid/int + test::one "Compute: invalid struct should fail" --exit=1 --stdout= \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/invalid/struct + + # Compute: success + test::one "Compute: noop should succeed" --exit=0 --stdout='{"empty":{}}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/success/noop + test::one "Compute: simple should succeed" --exit=0 --stdout="{}" \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/success/simple + test::one "Compute: overloading #Component should work" --exit=0 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/success/overload/flat + test::one "Compute: overloading #Component should work" --exit=0 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/success/overload/wrapped +} + +test::compute::dependencies(){ + local dagger="$1" + + test::one "Dependencies: simple direct dependency" --exit=0 --stdout='{"A":{"result":"from A"},"B":{"result":"dependency from A"}}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/dependencies/simple + test::one "Dependencies: interpolation" --exit=0 --stdout='{"A":{"result":"from A"},"B":{"result":"dependency from A"}}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/dependencies/interpolation + test::one "Dependencies: json.Unmarshal" --exit=0 --stdout='{"A":"{\"hello\": \"world\"}\n","B":{"result":"unmarshalled.hello=world"},"unmarshalled":{"hello":"world"}}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/dependencies/unmarshal +} + +test::compute::input(){ + local dagger="$1" + + # Compute: `--input-*` + test::one "Compute: Input: missing input should skip execution" --exit=0 --stdout='{}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/input/simple + + test::one "Compute: Input: simple input" --exit=0 --stdout='{"in":"foobar","test":"received: foobar"}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute --input-string 'in=foobar' "$d"/compute/input/simple + + test::one "Compute: Input: default values" --exit=0 --stdout='{"in":"default input","test":"received: default input"}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/input/default + + test::one "Compute: Input: override default value" --exit=0 --stdout='{"in":"foobar","test":"received: foobar"}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute --input-string 'in=foobar' "$d"/compute/input/default +} + +test::compute::daggerignore() { + test::one "Dagger Ignore" --exit=0 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute --input-dir TestData="$d"/compute/ignore/testdata "$d"/compute/ignore +} diff --git a/tests/test-examples.sh b/tests/test-examples.sh new file mode 100644 index 00000000..2131f845 --- /dev/null +++ b/tests/test-examples.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -o errexit -o errtrace -o functrace -o nounset -o pipefail + +# Test Directory +d=$(cd "$(dirname "${BASH_SOURCE[0]:-$PWD}")" 2>/dev/null 1>&2 && pwd) + +test::examples() { + local dagger="$1" + + test::secret "$d"/examples/react/inputs.yaml "examples: React" --exit=0 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/../examples/react +} diff --git a/tests/test-llb.sh b/tests/test-llb.sh new file mode 100644 index 00000000..fdfadee6 --- /dev/null +++ b/tests/test-llb.sh @@ -0,0 +1,187 @@ +#!/usr/bin/env bash +set -o errexit -o errtrace -o functrace -o nounset -o pipefail + +# Test Directory +d=$(cd "$(dirname "${BASH_SOURCE[0]:-$PWD}")" 2>/dev/null 1>&2 && pwd) + +test::llb(){ + local dagger="$1" + + test::llb::load "$dagger" + test::llb::mount "$dagger" + test::llb::copy "$dagger" + test::llb::local "$dagger" + test::llb::fetchcontainer "$dagger" + test::llb::pushcontainer "$dagger" + test::llb::fetchgit "$dagger" + test::llb::exec "$dagger" + test::llb::export "$dagger" + test::llb::subdir "$dagger" + test::llb::dockerbuild "$dagger" +} + +test::llb::load(){ + test::one "Load: valid components" --exit=0 --stdout='{"component":{},"test1":"lol","test2":"lol"}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/load/valid/component + test::one "Load: valid script" --exit=0 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/load/valid/script + + test::one "Load: invalid caching (FIXME https://github.com/blocklayerhq/dagger/issues/44)" --exit=1 --stdout= \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/load/invalid/cache +} + +test::llb::mount(){ + test::one "Mount: tmpfs" --exit=0 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/mounts/valid/tmpfs + + test::one "Mount: cache" --exit=0 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/mounts/valid/cache + + test::one "Mount: component" --exit=0 --stdout='{"test":"hello world"}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/mounts/valid/component + + disable test::one "Mount: script (FIXME https://github.com/blocklayerhq/dagger/issues/46)" --exit=0 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/mounts/valid/script +} + +test::llb::copy(){ + test::one "Copy: valid components" --exit=0 --stdout='{"component":{},"test1":"lol","test2":"lol"}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/copy/valid/component + test::one "Copy: valid script" --exit=0 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/copy/valid/script + + disable test::one "Copy: invalid caching (FIXME https://github.com/blocklayerhq/dagger/issues/44)" --exit=1 --stdout= \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/copy/invalid/cache +} + +test::llb::local(){ + disable "" "There are no local tests right now (the feature is possibly not functioning at all: see https://github.com/blocklayerhq/dagger/issues/41)" +} + +test::llb::fetchcontainer(){ + local dagger="$1" + + # Fetch container + disable test::one "FetchContainer: missing ref (FIXME: distinguish missing inputs from incorrect config)" --exit=1 --stdout= \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-container/invalid + test::one "FetchContainer: non existent container image" --exit=1 --stdout= \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-container/nonexistent/image + test::one "FetchContainer: non existent container tag" --exit=1 --stdout= \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-container/nonexistent/tag + test::one "FetchContainer: non existent container digest" --exit=1 --stdout= \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-container/nonexistent/digest + + test::one "FetchContainer: valid containers" --exit=0 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-container/exist + + disable test::one "FetchContainer: non existent container image with valid digest (FIXME https://github.com/blocklayerhq/dagger/issues/32)" --exit=1 --stdout= \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-container/nonexistent/image-with-valid-digest +} + +test::llb::pushcontainer(){ + local dagger="$1" + + test::secret "$d"/llb/push-container/inputs.yaml "PushContainer: simple" --exit=0 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/push-container +} + +test::llb::fetchgit(){ + local dagger="$1" + + # Fetch git + test::one "FetchGit: valid" --exit=0 --stdout="{}" \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-git/exist + disable test::one "FetchGit: invalid (FIXME: distinguish missing inputs from incorrect config) " --exit=1 --stdout= \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-git/invalid + test::one "FetchGit: non existent remote" --exit=1 --stdout= \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-git/nonexistent/remote + test::one "FetchGit: non existent ref" --exit=1 --stdout= \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-git/nonexistent/ref + test::one "FetchGit: non existent bork" --exit=1 --stdout= \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-git/nonexistent/bork +} + +test::llb::exec(){ + # Exec + test::one "Exec: invalid" --exit=1 --stdout= \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/invalid + test::one "Exec: error" --exit=1 --stdout= \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/error + test::one "Exec: simple" --exit=0 --stdout={} \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/simple + # XXX should run twice and test that the string "always output" is visible with DOCKER_OUTPUT=1 + # Alternatively, use export, but this would test multiple things then... + test::one "Exec: always" --exit=0 --stdout={} \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/always + test::one "Exec: env invalid" --exit=1 --stdout= \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/env/invalid + test::one "Exec: env valid" --exit=0 --stdout={} \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/env/valid + test::one "Exec: env with overlay" --exit=0 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute --input-string 'bar=overlay environment' "$d"/llb/exec/env/overlay + + test::one "Exec: non existent dir" --exit=0 --stdout={} \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/dir/doesnotexist + test::one "Exec: valid dir" --exit=0 --stdout={} \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/dir/exist + + disable test::one "Exec: exit code propagation (FIXME https://github.com/blocklayerhq/dagger/issues/74)" --exit=123 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/exit_code + + test::one "Exec: script with referenced non-concrete property should not be executed, and should succeed overall" --exit=0 --stdout='{"hello":"world"}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/undefined/non_concrete_referenced + # NOTE: the exec is meant to fail - and we test that as a way to confirm it has been executed + test::one "Exec: script with unreferenced undefined properties should be executed" --exit=1 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/undefined/non_concrete_not_referenced + test::one "Exec: package with optional def, not referenced, should be executed" --exit=0 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/undefined/with_pkg_def + test::one "Exec: script with optional prop, not referenced, should be executed" --exit=0 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/undefined/with_pkg_optional + disable test::one "Exec: script with non-optional prop, not referenced, should be executed (FIXME https://github.com/blocklayerhq/dagger/issues/70)" --exit=1 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/undefined/with_pkg_mandatory +} + +test::llb::export(){ + test::one "Export: json" --exit=0 --stdout='{"testMap":{"something":"something"},"testScalar":true}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/json + + test::one "Export: string" --exit=0 --stdout='{"test":"something"}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/string + + test::one "Export: string with additional constraint success" --exit=0 --stdout='{"test":"something"}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/withvalidation + + test::one "Export: many concurrent" --exit=0 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/concurrency + + test::one "Export: does not pass additional validation" --exit=1 --stdout= \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/invalid/validation + + test::one "Export: invalid format" --exit=1 --stdout= \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/invalid/format + + test::one "Export: invalid path" --exit=1 --stdout= \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/invalid/path + + test::one "Export: number" --exit=0 --stdout='{"test":-123.5}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/float + + disable test::one "Export: number (FIXME: https://github.com/blocklayerhq/dagger/issues/96)" --exit=0 --stdout='{"test":-123.5}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/number + + test::one "Export: yaml" --exit=0 --stdout='{"testMap":{"something":"something"},"testScalar":true}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/yaml + + test::one "Export: bool" --exit=0 --stdout='{"test":true}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/bool +} + +test::llb::subdir() { + test::one "Subdir: simple usage" --exit=0 --stdout='{"hello":"world"}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/subdir/simple +} + +test::llb::dockerbuild() { + test::one "Docker Build" --exit=0 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute --input-dir TestData="$d"/llb/dockerbuild/testdata "$d"/llb/dockerbuild +} diff --git a/tests/test-stdlib.sh b/tests/test-stdlib.sh new file mode 100644 index 00000000..40eac0ab --- /dev/null +++ b/tests/test-stdlib.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -o errexit -o errtrace -o functrace -o nounset -o pipefail + +# Test Directory +d=$(cd "$(dirname "${BASH_SOURCE[0]:-$PWD}")" 2>/dev/null 1>&2 && pwd) + +test::stdlib(){ + local dagger="$1" + + test::one "stdlib: alpine" \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/stdlib/alpine + test::one "stdlib: yarn" \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/stdlib/yarn --input-dir TestData="$d"/stdlib/yarn/testdata + test::one "stdlib: go" \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/stdlib/go --input-dir TestData="$d"/stdlib/go/testdata + test::one "stdlib: file" \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/stdlib/file + test::secret "$d"/stdlib/netlify/inputs.yaml "stdlib: netlify" \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/stdlib/netlify +} diff --git a/tests/test.sh b/tests/test.sh index 49b898dd..b7a4f333 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -1,10 +1,7 @@ #!/usr/bin/env bash set -o errexit -o errtrace -o functrace -o nounset -o pipefail -# Source the lib -readonly d=$(cd "$(dirname "${BASH_SOURCE[0]:-$PWD}")" 2>/dev/null 1>&2 && pwd) -# shellcheck source=/dev/null -. "$d/test-lib.sh" +readonly SUITE="${SUITE:-""}" # Point this to your dagger binary readonly DAGGER_BINARY="${DAGGER_BINARY:-$d/../cmd/dagger/dagger}" @@ -13,350 +10,30 @@ DAGGER_BINARY_ARGS="${DAGGER_BINARY_ARGS:---log-format json}" read -ra DAGGER_BINARY_ARGS <<< "${DAGGER_BINARY_ARGS:-}" readonly DAGGER_BINARY_ARGS +# Test Directory +d=$(cd "$(dirname "${BASH_SOURCE[0]:-$PWD}")" 2>/dev/null 1>&2 && pwd) +# Source the lib +# shellcheck source=/dev/null +. "$d/test-lib.sh" +# shellcheck source=/dev/null +. "$d/test-compute.sh" +# shellcheck source=/dev/null +. "$d/test-llb.sh" +# shellcheck source=/dev/null +. "$d/test-stdlib.sh" +# shellcheck source=/dev/null +. "$d/test-cli.sh" +# shellcheck source=/dev/null +. "$d/test-examples.sh" + test::all(){ local dagger="$1" - test::llb "$dagger" - test::stdlib "$dagger" - test::dependencies "$dagger" - test::compute "$dagger" - test::daggerignore "$dagger" - test::cli "$dagger" - test::examples "$dagger" -} - -test::llb(){ - local dagger="$1" - - test::llb::load "$dagger" - test::llb::mount "$dagger" - test::llb::copy "$dagger" - test::llb::local "$dagger" - test::llb::fetchcontainer "$dagger" - test::llb::pushcontainer "$dagger" - test::llb::fetchgit "$dagger" - test::llb::exec "$dagger" - test::llb::export "$dagger" - test::llb::subdir "$dagger" - test::llb::dockerbuild "$dagger" -} - -test::stdlib(){ - local dagger="$1" - - test::one "stdlib: alpine" \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/stdlib/alpine - test::one "stdlib: yarn" \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/stdlib/yarn --input-dir TestData="$d"/stdlib/yarn/testdata - test::one "stdlib: go" \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/stdlib/go --input-dir TestData="$d"/stdlib/go/testdata - test::one "stdlib: file" \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/stdlib/file - test::secret "$d"/stdlib/netlify/inputs.yaml "stdlib: netlify" \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/stdlib/netlify -} - -test::dependencies(){ - local dagger="$1" - - test::one "Dependencies: simple direct dependency" --exit=0 --stdout='{"A":{"result":"from A"},"B":{"result":"dependency from A"}}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/dependencies/simple - test::one "Dependencies: interpolation" --exit=0 --stdout='{"A":{"result":"from A"},"B":{"result":"dependency from A"}}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/dependencies/interpolation - test::one "Dependencies: json.Unmarshal" --exit=0 --stdout='{"A":"{\"hello\": \"world\"}\n","B":{"result":"unmarshalled.hello=world"},"unmarshalled":{"hello":"world"}}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/dependencies/unmarshal -} - -test::compute(){ - local dagger="$1" - - # Compute: invalid syntax - test::one "Compute: invalid string should fail" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/invalid/string - test::one "Compute: invalid bool should fail" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/invalid/bool - test::one "Compute: invalid int should fail" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/invalid/int - test::one "Compute: invalid struct should fail" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/invalid/struct - - # Compute: success - test::one "Compute: noop should succeed" --exit=0 --stdout='{"empty":{}}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/success/noop - test::one "Compute: simple should succeed" --exit=0 --stdout="{}" \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/success/simple - test::one "Compute: overloading #Component should work" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/success/overload/flat - test::one "Compute: overloading #Component should work" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/success/overload/wrapped - - # Compute: `--input-*` - test::one "Compute: Input: missing input should skip execution" --exit=0 --stdout='{}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/input/simple - - test::one "Compute: Input: simple input" --exit=0 --stdout='{"in":"foobar","test":"received: foobar"}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute --input-string 'in=foobar' "$d"/compute/input/simple - - test::one "Compute: Input: default values" --exit=0 --stdout='{"in":"default input","test":"received: default input"}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/input/default - - test::one "Compute: Input: override default value" --exit=0 --stdout='{"in":"foobar","test":"received: foobar"}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute --input-string 'in=foobar' "$d"/compute/input/default - -} - -test::daggerignore() { - test::one "Dagger Ignore" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute --input-dir TestData="$d"/ignore/testdata "$d"/ignore -} - -test::cli() { - local dagger="$1" - - test::cli::list "$dagger" - test::cli::newdir "$dagger" - test::cli::query "$dagger" -} - -test::cli::list() { - local dagger="$1" - - # Create temporary store - local DAGGER_STORE - DAGGER_STORE="$(mktemp -d -t dagger-store-XXXXXX)" - export DAGGER_STORE - - test::one "CLI: list: no deployments" --stdout="" \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" list - - test::one "CLI: list: create deployment" \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/simple simple - - test::one "CLI: list: with deployments" --stdout="simple" \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" list -} - -test::cli::newdir() { - local dagger="$1" - - # Create temporary store - local DAGGER_STORE - DAGGER_STORE="$(mktemp -d -t dagger-store-XXXXXX)" - export DAGGER_STORE - - test::one "CLI: new: --plan-dir" \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/simple simple - - test::one "CLI: new: duplicate name" --exit=1 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/simple simple - - test::one "CLI: new: verify plan can be upped" \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" up -d "simple" - - test::one "CLI: new: verify we have the right plan" --stdout='{ - foo: "value" - bar: "another value" -}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple" -c -} - -test::cli::query() { - local dagger="$1" - - # Create temporary store - local DAGGER_STORE - DAGGER_STORE="$(mktemp -d -t dagger-store-XXXXXX)" - export DAGGER_STORE - - test::one "CLI: query: initialize simple" \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/simple simple - - test::one "CLI: query: concrete" --stdout='{ - foo: "value" - bar: "another value" -}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple" -c - - test::one "CLI: query: target" --stdout='"value"' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple" foo - - test::one "CLI: query: initialize nonconcrete" \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/nonconcrete nonconcrete - - test::one "CLI: query: non concrete" --exit=1 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "nonconcrete" -c -} - -test::examples() { - test::secret "$d"/../examples/react-netlify/inputs.yaml "examples: React Netlify" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/../examples/react-netlify - -} - -test::llb::fetchcontainer(){ - local dagger="$1" - - # Fetch container - disable test::one "FetchContainer: missing ref (FIXME: distinguish missing inputs from incorrect config)" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-container/invalid - test::one "FetchContainer: non existent container image" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-container/nonexistent/image - test::one "FetchContainer: non existent container tag" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-container/nonexistent/tag - test::one "FetchContainer: non existent container digest" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-container/nonexistent/digest - - test::one "FetchContainer: valid containers" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-container/exist - - disable test::one "FetchContainer: non existent container image with valid digest (FIXME https://github.com/blocklayerhq/dagger/issues/32)" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-container/nonexistent/image-with-valid-digest -} - -test::llb::pushcontainer(){ - local dagger="$1" - - test::secret "$d"/llb/push-container/inputs.yaml "PushContainer: simple" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/push-container -} - -test::llb::fetchgit(){ - local dagger="$1" - - # Fetch git - test::one "FetchGit: valid" --exit=0 --stdout="{}" \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-git/exist - disable test::one "FetchGit: invalid (FIXME: distinguish missing inputs from incorrect config) " --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-git/invalid - test::one "FetchGit: non existent remote" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-git/nonexistent/remote - test::one "FetchGit: non existent ref" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-git/nonexistent/ref - test::one "FetchGit: non existent bork" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/fetch-git/nonexistent/bork -} - -test::llb::exec(){ - # Exec - test::one "Exec: invalid" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/invalid - test::one "Exec: error" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/error - test::one "Exec: simple" --exit=0 --stdout={} \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/simple - # XXX should run twice and test that the string "always output" is visible with DOCKER_OUTPUT=1 - # Alternatively, use export, but this would test multiple things then... - test::one "Exec: always" --exit=0 --stdout={} \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/always - test::one "Exec: env invalid" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/env/invalid - test::one "Exec: env valid" --exit=0 --stdout={} \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/env/valid - test::one "Exec: env with overlay" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute --input-string 'bar=overlay environment' "$d"/llb/exec/env/overlay - - test::one "Exec: non existent dir" --exit=0 --stdout={} \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/dir/doesnotexist - test::one "Exec: valid dir" --exit=0 --stdout={} \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/dir/exist - - disable test::one "Exec: exit code propagation (FIXME https://github.com/blocklayerhq/dagger/issues/74)" --exit=123 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/exit_code - - test::one "Exec: script with referenced non-concrete property should not be executed, and should succeed overall" --exit=0 --stdout='{"hello":"world"}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/undefined/non_concrete_referenced - # NOTE: the exec is meant to fail - and we test that as a way to confirm it has been executed - test::one "Exec: script with unreferenced undefined properties should be executed" --exit=1 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/undefined/non_concrete_not_referenced - test::one "Exec: package with optional def, not referenced, should be executed" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/undefined/with_pkg_def - test::one "Exec: script with optional prop, not referenced, should be executed" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/undefined/with_pkg_optional - disable test::one "Exec: script with non-optional prop, not referenced, should be executed (FIXME https://github.com/blocklayerhq/dagger/issues/70)" --exit=1 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/exec/undefined/with_pkg_mandatory -} - -test::llb::export(){ - test::one "Export: json" --exit=0 --stdout='{"testMap":{"something":"something"},"testScalar":true}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/json - - test::one "Export: string" --exit=0 --stdout='{"test":"something"}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/string - - test::one "Export: string with additional constraint success" --exit=0 --stdout='{"test":"something"}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/withvalidation - - test::one "Export: many concurrent" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/concurrency - - test::one "Export: does not pass additional validation" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/invalid/validation - - test::one "Export: invalid format" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/invalid/format - - test::one "Export: invalid path" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/invalid/path - - test::one "Export: number" --exit=0 --stdout='{"test":-123.5}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/float - - disable test::one "Export: number (FIXME: https://github.com/blocklayerhq/dagger/issues/96)" --exit=0 --stdout='{"test":-123.5}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/number - - test::one "Export: yaml" --exit=0 --stdout='{"testMap":{"something":"something"},"testScalar":true}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/yaml - - test::one "Export: bool" --exit=0 --stdout='{"test":true}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/export/bool -} - -test::llb::copy(){ - test::one "Copy: valid components" --exit=0 --stdout='{"component":{},"test1":"lol","test2":"lol"}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/copy/valid/component - test::one "Copy: valid script" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/copy/valid/script - - disable test::one "Copy: invalid caching (FIXME https://github.com/blocklayerhq/dagger/issues/44)" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/copy/invalid/cache -} - -test::llb::load(){ - test::one "Load: valid components" --exit=0 --stdout='{"component":{},"test1":"lol","test2":"lol"}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/load/valid/component - test::one "Load: valid script" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/load/valid/script - - test::one "Load: invalid caching (FIXME https://github.com/blocklayerhq/dagger/issues/44)" --exit=1 --stdout= \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/load/invalid/cache -} - -test::llb::local(){ - disable "" "There are no local tests right now (the feature is possibly not functioning at all: see https://github.com/blocklayerhq/dagger/issues/41)" -} - -test::llb::mount(){ - test::one "Mount: tmpfs" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/mounts/valid/tmpfs - - test::one "Mount: cache" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/mounts/valid/cache - - test::one "Mount: component" --exit=0 --stdout='{"test":"hello world"}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/mounts/valid/component - - disable test::one "Mount: script (FIXME https://github.com/blocklayerhq/dagger/issues/46)" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/mounts/valid/script -} - -test::llb::subdir() { - test::one "Subdir: simple usage" --exit=0 --stdout='{"hello":"world"}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/llb/subdir/simple -} - -test::llb::dockerbuild() { - test::one "Docker Build" --exit=0 \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute --input-dir TestData="$d"/llb/dockerbuild/testdata "$d"/llb/dockerbuild + [ -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" } case "${1:-all}" in From 98c4dc790c357846450061f25b23b87348eeb709 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Thu, 1 Apr 2021 19:13:08 -0700 Subject: [PATCH 2/2] 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