diff --git a/task_test.go b/task_test.go index 0006b674..3e98802c 100644 --- a/task_test.go +++ b/task_test.go @@ -575,3 +575,22 @@ func readTestFixture(t *testing.T, dir string, file string) string { assert.NoError(t, err, "error reading text fixture") return string(b) } + +func TestWhenNoDirAttributeItRunsInSameDirAsTaskfile(t *testing.T) { + const expected = "dir" + const dir = "testdata/" + expected + var out bytes.Buffer + e := &task.Executor{ + Dir: dir, + Stdout: &out, + Stderr: &out, + } + + assert.NoError(t, e.Setup()) + assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "whereami"})) + + // got should be the "dir" part of "testdata/dir" + got := strings.TrimSuffix(filepath.Base(out.String()), "\n") + assert.Equal(t, expected, got, "Mismatch in the working directory") +} + diff --git a/testdata/dir/Taskfile.yml b/testdata/dir/Taskfile.yml new file mode 100644 index 00000000..f17dd9fe --- /dev/null +++ b/testdata/dir/Taskfile.yml @@ -0,0 +1,7 @@ +version: '2' + +tasks: + whereami: + cmds: + - pwd + silent: true