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:
parent
81baf808c9
commit
1e93c38307
17
task_test.go
17
task_test.go
@ -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")
|
||||
}
|
||||
|
||||
|
8
testdata/dir/explicit_exists/Taskfile.yml
vendored
Normal file
8
testdata/dir/explicit_exists/Taskfile.yml
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
version: '2'
|
||||
|
||||
tasks:
|
||||
whereami:
|
||||
dir: exists
|
||||
cmds:
|
||||
- pwd
|
||||
silent: true
|
0
testdata/dir/explicit_exists/exists/.keepme
vendored
Normal file
0
testdata/dir/explicit_exists/exists/.keepme
vendored
Normal file
Loading…
x
Reference in New Issue
Block a user