mirror of
https://github.com/go-task/task.git
synced 2025-11-23 22:24:45 +02:00
Make dynamic variables run on the right directory
It was always running in the main Taskfile dir, even when the variable was declared in an included taskfile in another directory or when task had a custom dir. Closes #384
This commit is contained in:
19
task_test.go
19
task_test.go
@@ -303,16 +303,15 @@ func TestPrecondition(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGenerates(t *testing.T) {
|
||||
const dir = "testdata/generates"
|
||||
|
||||
const (
|
||||
srcTask = "sub/src.txt"
|
||||
relTask = "rel.txt"
|
||||
absTask = "abs.txt"
|
||||
absTask = "sub/abs.txt"
|
||||
fileWithSpaces = "my text file.txt"
|
||||
)
|
||||
|
||||
// This test does not work with a relative dir.
|
||||
dir, err := filepath.Abs("testdata/generates")
|
||||
assert.NoError(t, err)
|
||||
var srcFile = filepath.Join(dir, srcTask)
|
||||
|
||||
for _, task := range []string{srcTask, relTask, absTask, fileWithSpaces} {
|
||||
@@ -800,6 +799,18 @@ func TestWhenDirAttributeItCreatesMissingAndRunsInThatDir(t *testing.T) {
|
||||
_ = os.RemoveAll(toBeCreated)
|
||||
}
|
||||
|
||||
func TestDynamicVariablesShouldRunOnTheTaskDir(t *testing.T) {
|
||||
tt := fileContentTest{
|
||||
Dir: "testdata/dir/dynamic_var",
|
||||
Target: "default",
|
||||
TrimSpace: false,
|
||||
Files: map[string]string{
|
||||
"subdirectory/dir.txt": "subdirectory\n",
|
||||
},
|
||||
}
|
||||
tt.Run(t)
|
||||
}
|
||||
|
||||
func TestDisplaysErrorOnUnsupportedVersion(t *testing.T) {
|
||||
e := task.Executor{
|
||||
Dir: "testdata/version/v1",
|
||||
|
||||
Reference in New Issue
Block a user