From cfa9f08bc92cdd832d75e1b8fb4be302d107fac6 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Thu, 15 Apr 2021 12:10:14 -0700 Subject: [PATCH] tests: added test to ensure an op.#Exec with no cache will not execute twice Signed-off-by: Sam Alba --- tests/compute/success/exec-nocache/main.cue | 25 +++++++++++++++++++++ tests/test-compute.sh | 2 ++ 2 files changed, 27 insertions(+) create mode 100644 tests/compute/success/exec-nocache/main.cue diff --git a/tests/compute/success/exec-nocache/main.cue b/tests/compute/success/exec-nocache/main.cue new file mode 100644 index 00000000..0a4152e8 --- /dev/null +++ b/tests/compute/success/exec-nocache/main.cue @@ -0,0 +1,25 @@ +package main + +import ( + "dagger.io/alpine" + "dagger.io/dagger/op" +) + +rand: { + string + + #up: [ + op.#Load & {from: alpine.#Image}, + op.#Exec & { + always: true + args: ["sh", "-c", """ + tr -dc A-Za-z0-9 /id + """] + }, + op.#Export & {source: "/id"}, + ] +} + +// If rand is executed twice, cue won't validate +ref1: rand +ref2: ref1 diff --git a/tests/test-compute.sh b/tests/test-compute.sh index 324d9a64..7d5c22e2 100644 --- a/tests/test-compute.sh +++ b/tests/test-compute.sh @@ -35,6 +35,8 @@ test::compute::simple(){ "$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::one "Compute: Disabling the cache on exec should not compute twice when referenced by another key" --exit=0 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/success/exec-nocache } test::compute::dependencies(){