diff --git a/tests/plan.bats b/tests/plan.bats index a00f5eec..c4dbef51 100644 --- a/tests/plan.bats +++ b/tests/plan.bats @@ -4,6 +4,35 @@ setup() { common_setup } +@test "plan/do dynamic tasks - fails to find tasks" { + # Europa loader handles the cwd differently, therefore we need to CD into the tree at or below the parent of cue.mod + cd "$TESTDIR" + run "$DAGGER" "do" -p ./plan/do/dynamic_tasks.cue test b + # No output because of weirdness with dynamic tasks, which causes it to fail + refute_output --partial "actions.test.b" +} + +@test "plan/do dynamic tasks - fails to run tasks" { + run "$DAGGER" "do" -p ./plan/do/dynamic_tasks.cue "test" + refute_output --partial 'actions.test.b.y' +} + +@test "plan/do don't run unspecified tasks" { + run "$DAGGER" "do" -p ./plan/do/do_not_run_unspecified_tasks.cue test + assert_output --partial "actions.test.one.script" + assert_output --partial "actions.test.three.script" + assert_output --partial "actions.test.two.script" + assert_output --partial "actions.image" + assert_output --partial "actions.test.one" + assert_output --partial "actions.test.two" + assert_output --partial "actions.test.three" + assert_output --partial "actions.test.one.export" + assert_output --partial 'client.filesystem."./test_do".write' + refute_output --partial "actions.notMe" + refute_output --partial 'client.filesystem."./dependent_do".write' +} + + @test "plan/hello" { # Europa loader handles the cwd differently, therefore we need to CD into the tree at or below the parent of cue.mod cd "$TESTDIR" diff --git a/tests/plan/do/do_not_run_unspecified_tasks.cue b/tests/plan/do/do_not_run_unspecified_tasks.cue new file mode 100644 index 00000000..549ae046 --- /dev/null +++ b/tests/plan/do/do_not_run_unspecified_tasks.cue @@ -0,0 +1,57 @@ +package main + +import ( + "dagger.io/dagger" + + "universe.dagger.io/alpine" + "universe.dagger.io/bash" +) + +dagger.#Plan & { + client: filesystem: "./test_do": write: contents: actions.test.one.export.files["/output.txt"] + client: filesystem: "./dependent_do": write: contents: actions.dependent.one.export.files["/output.txt"] + + outputs: files: dependent: { + dest: "./dependent_do" + contents: actions.dependent.one.export.files["/output.txt"] + } + + actions: { + image: alpine.#Build & { + packages: bash: {} + } + + test: { + one: bash.#Run & { + input: image.output + script: contents: "echo Hello World! > /output.txt" + export: files: "/output.txt": string + } + + two: bash.#Run & { + input: image.output + script: contents: "true" + } + + three: bash.#Run & { + input: image.output + script: contents: "cat /one/output.txt" + mounts: output: { + contents: one.export.rootfs + dest: "/one" + } + } + } + + dependent: one: bash.#Run & { + input: test.one.output + script: contents: "cat /output.txt" + export: files: "/output.txt": string + } + + notMe: bash.#Run & { + input: image.output + script: contents: "false" + } + } +} diff --git a/tests/plan/do/dynamic_tasks.cue b/tests/plan/do/dynamic_tasks.cue new file mode 100644 index 00000000..47d75baf --- /dev/null +++ b/tests/plan/do/dynamic_tasks.cue @@ -0,0 +1,46 @@ +package main + +import ( + "dagger.io/dagger" + + "universe.dagger.io/alpine" + "universe.dagger.io/bash" +) + +dagger.#Plan & { + client: filesystem: "./dagger_do": write: contents: actions.test.b.y.export.files["/output.txt"] + + actions: { + image: alpine.#Build & { + packages: bash: {} + } + + test: { + a: bash.#Run & { + input: image.output + script: contents: "echo -n 'from dagger with love' > /output.txt" + export: files: "/output.txt": string + } + b: { + x: bash.#Run & { + input: image.output + script: contents: "echo -n testing > /output.txt" + export: files: "/output.txt": string + } + // This fails. Building the Actions lookup table breaks + if x.export.files["/output.txt"] == "testing" { + y: bash.#Run & { + input: a.output + script: contents: "echo -n hello from y" + export: files: "/output.txt": string + } + } + } + } + + notMe: bash.#Run & { + input: image.output + script: contents: "false" + } + } +}