From 907430d40994b89fb428d27102d90e5c49377bb2 Mon Sep 17 00:00:00 2001 From: Tom Chauveau Date: Sat, 24 Apr 2021 19:31:36 +0200 Subject: [PATCH 1/2] Fix Subdir op Signed-off-by: Tom Chauveau --- dagger/pipeline.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dagger/pipeline.go b/dagger/pipeline.go index 1741ca49..f0ca2999 100644 --- a/dagger/pipeline.go +++ b/dagger/pipeline.go @@ -234,7 +234,7 @@ func (p *Pipeline) Subdir(ctx context.Context, op *compiler.Value, st llb.State) if err != nil { return st, err } - return st.File( + return llb.Scratch().File( llb.Copy( st, dir, From 57256eb8c4e26cc1ebbccc264eb70b2d687d59c7 Mon Sep 17 00:00:00 2001 From: Tom Chauveau Date: Sat, 24 Apr 2021 19:32:02 +0200 Subject: [PATCH 2/2] Add tests for Subdir operation Signed-off-by: Tom Chauveau --- tests/ops.bats | 3 +++ tests/ops/subdir/error/main.cue | 31 +++++++++++++++++++++++++++++++ tests/ops/subdir/simple/main.cue | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tests/ops/subdir/error/main.cue diff --git a/tests/ops.bats b/tests/ops.bats index f3f6be81..83fce481 100644 --- a/tests/ops.bats +++ b/tests/ops.bats @@ -207,6 +207,9 @@ setup() { run "$DAGGER" compute "$TESTDIR"/ops/subdir/simple assert_success assert_line '{"hello":"world"}' + + run "$DAGGER" compute "$TESTDIR"/ops/subdir/error + assert_failure } @test "op.#DockerBuild" { diff --git a/tests/ops/subdir/error/main.cue b/tests/ops/subdir/error/main.cue new file mode 100644 index 00000000..9fb09742 --- /dev/null +++ b/tests/ops/subdir/error/main.cue @@ -0,0 +1,31 @@ +package main + +import "dagger.io/dagger/op" + +hello: { + string + + #up: [ + op.#FetchContainer & { + ref: "alpine" + }, + op.#Exec & { + args: ["mkdir", "-p", "/tmp/foo"] + }, + op.#Exec & { + args: ["sh", "-c", "echo -n world > /tmp/foo/hello"] + }, + op.#Subdir & { + dir: "/tmp/foo" + }, + // Should FAIL + op.#Exec & { + always: true + args: ["ls"] + }, + op.#Export & { + source: "./hello" + format: "string" + }, + ] +} diff --git a/tests/ops/subdir/simple/main.cue b/tests/ops/subdir/simple/main.cue index 1cb98ffb..0fde946f 100644 --- a/tests/ops/subdir/simple/main.cue +++ b/tests/ops/subdir/simple/main.cue @@ -19,7 +19,7 @@ hello: { dir: "/tmp/foo" }, op.#Export & { - source: "/hello" + source: "./hello" format: "string" }, ]