Add do
tests
Signed-off-by: Joel Longtine <joel@dagger.io>
This commit is contained in:
parent
2a6962ddc8
commit
5afaedc9ab
@ -4,6 +4,35 @@ setup() {
|
|||||||
common_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
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "plan/do dynamic tasks - fails to run tasks" {
|
||||||
|
run "$DAGGER" "do" -p ./plan/do/dynamic_tasks.cue "test"
|
||||||
|
assert_failure
|
||||||
|
assert_output --partial 'outputs.files.andrea: contents is not set'
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 "outputs.files.test"
|
||||||
|
refute_output --partial "actions.notMe"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@test "plan/hello" {
|
@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
|
# Europa loader handles the cwd differently, therefore we need to CD into the tree at or below the parent of cue.mod
|
||||||
cd "$TESTDIR"
|
cd "$TESTDIR"
|
||||||
|
57
tests/plan/do/disconnected_outputs_weirdness.cue
Normal file
57
tests/plan/do/disconnected_outputs_weirdness.cue
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"dagger.io/dagger"
|
||||||
|
|
||||||
|
"universe.dagger.io/alpine"
|
||||||
|
"universe.dagger.io/bash"
|
||||||
|
)
|
||||||
|
|
||||||
|
dagger.#Plan & {
|
||||||
|
// This is acting weird...
|
||||||
|
// I don't understand why `cue/flow` thinks that outputs.files.test has a dependency
|
||||||
|
// on actions.fromAndrea.a.export._files."/output.txt"._read
|
||||||
|
// It _does_ fail correctly, FWIW, when it reaches this code.
|
||||||
|
// TASK: outputs.files.test
|
||||||
|
// DEPENDENCIES:
|
||||||
|
// actions.fromAndrea.a.export._files."/output.txt"._read
|
||||||
|
// actions.image._dag."1"._exec
|
||||||
|
// actions.image._dag."0"._op
|
||||||
|
outputs: files: test: {
|
||||||
|
dest: "./test_do"
|
||||||
|
contents: actions.test1.one.export.files["/output.txt"]
|
||||||
|
}
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
image: alpine.#Build & {
|
||||||
|
packages: bash: {}
|
||||||
|
}
|
||||||
|
|
||||||
|
abcAction: {
|
||||||
|
a: bash.#Run & {
|
||||||
|
input: image.output
|
||||||
|
script: contents: "echo -n 'from andrea with love' > /output.txt"
|
||||||
|
export: files: "/output.txt": string
|
||||||
|
}
|
||||||
|
b: {
|
||||||
|
x: bash.#Run & {
|
||||||
|
input: image.output
|
||||||
|
script: contents: "echo -n false > /output.txt"
|
||||||
|
export: files: "/output.txt": string
|
||||||
|
}
|
||||||
|
if x.export.files["/output.txt"] == "false" {
|
||||||
|
y: bash.#Run & {
|
||||||
|
input: a.output
|
||||||
|
script: contents: "echo -n hello from y"
|
||||||
|
export: files: "/output.txt": "from andrea with love"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
notMe: bash.#Run & {
|
||||||
|
input: image.output
|
||||||
|
script: contents: "false"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
61
tests/plan/do/do_not_run_unspecified_tasks.cue
Normal file
61
tests/plan/do/do_not_run_unspecified_tasks.cue
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"dagger.io/dagger"
|
||||||
|
|
||||||
|
"universe.dagger.io/alpine"
|
||||||
|
"universe.dagger.io/bash"
|
||||||
|
)
|
||||||
|
|
||||||
|
dagger.#Plan & {
|
||||||
|
outputs: files: test: {
|
||||||
|
dest: "./test_do"
|
||||||
|
contents: actions.test.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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
49
tests/plan/do/dynamic_tasks.cue
Normal file
49
tests/plan/do/dynamic_tasks.cue
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"dagger.io/dagger"
|
||||||
|
|
||||||
|
"universe.dagger.io/alpine"
|
||||||
|
"universe.dagger.io/bash"
|
||||||
|
)
|
||||||
|
|
||||||
|
dagger.#Plan & {
|
||||||
|
outputs: files: andrea: {
|
||||||
|
dest: "./andrea_do"
|
||||||
|
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 andrea 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"
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user