From 75fbddf6be07c5bd2414b06d1534d3bd061054e6 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Mon, 25 Jan 2021 16:18:58 -0800 Subject: [PATCH] op: exec: fix `dir` Fixes #30 Signed-off-by: Andrea Luzzardi --- dagger/op.go | 2 ++ examples/tests/exec/dir/doesnotexist/main.cue | 5 ++++- examples/tests/test.sh | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/dagger/op.go b/dagger/op.go index 0f39a2dc..7636ce90 100644 --- a/dagger/op.go +++ b/dagger/op.go @@ -171,6 +171,8 @@ func (op *Op) Exec(ctx context.Context, fs FS, out *Fillable) (FS, error) { opts = append(opts, llb.WithCustomName(op.v.Path().String())) // args opts = append(opts, llb.Args(cmd.Args)) + // dir + opts = append(opts, llb.Dir(cmd.Dir)) // env for k, v := range cmd.Env { opts = append(opts, llb.AddEnv(k, v)) diff --git a/examples/tests/exec/dir/doesnotexist/main.cue b/examples/tests/exec/dir/doesnotexist/main.cue index d59baa8f..f11b3a6b 100644 --- a/examples/tests/exec/dir/doesnotexist/main.cue +++ b/examples/tests/exec/dir/doesnotexist/main.cue @@ -7,7 +7,10 @@ package testing }, { do: "exec" - args: ["sh", "-c", "echo should not succeed"] + args: ["sh", "-c", """ + echo "pwd is: $(pwd)" + [ "$(pwd)" == "/thisisnonexistent" ] || exit 1 + """] dir: "/thisisnonexistent" }, ] diff --git a/examples/tests/test.sh b/examples/tests/test.sh index 49976e7b..338ef92e 100755 --- a/examples/tests/test.sh +++ b/examples/tests/test.sh @@ -88,9 +88,9 @@ test::exec(){ test::one "Exec: env with overlay" --exit=0 \ "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute --input 'bar: "overlay environment"' "$d"/exec/env/overlay - disable test::one "Exec: non existent dir (FIXME https://github.com/blocklayerhq/dagger/issues/30)" --exit=0 --stdout={} \ + test::one "Exec: non existent dir" --exit=0 --stdout={} \ "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/exec/dir/doesnotexist - disable test::one "Exec: valid dir (FIXME https://github.com/blocklayerhq/dagger/issues/30)" --exit=0 --stdout={} \ + test::one "Exec: valid dir" --exit=0 --stdout={} \ "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/exec/dir/exist }