1
0
mirror of https://github.com/go-task/task.git synced 2025-02-09 13:47:06 +02:00

Task directory: test when "dir:" attribute points to an existing dir

This commit is contained in:
Marco Molteni 2019-06-04 18:36:35 +02:00
parent 81baf808c9
commit 1e93c38307
3 changed files with 25 additions and 0 deletions

View File

@ -594,3 +594,20 @@ func TestWhenNoDirAttributeItRunsInSameDirAsTaskfile(t *testing.T) {
assert.Equal(t, expected, got, "Mismatch in the working directory")
}
func TestWhenDirAttributeAndDirExistsItRunsInThatDir(t *testing.T) {
const expected = "exists"
const dir = "testdata/dir/explicit_exists"
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 := strings.TrimSuffix(filepath.Base(out.String()), "\n")
assert.Equal(t, expected, got, "Mismatch in the working directory")
}

View File

@ -0,0 +1,8 @@
version: '2'
tasks:
whereami:
dir: exists
cmds:
- pwd
silent: true

View File