mirror of
https://github.com/go-task/task.git
synced 2025-01-04 03:48:02 +02:00
Write first test for including a Taskfile
This commit is contained in:
parent
db280adf55
commit
5a28560177
@ -23,6 +23,7 @@ func Taskfile(dir string) (*taskfile.Taskfile, error) {
|
||||
}
|
||||
|
||||
for namespace, path := range t.Includes {
|
||||
path = filepath.Join(dir, path)
|
||||
info, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
13
task_test.go
13
task_test.go
@ -470,3 +470,16 @@ func TestDry(t *testing.T) {
|
||||
t.Errorf("File should not exist %s", file)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIncludes(t *testing.T) {
|
||||
tt := fileContentTest{
|
||||
Dir: "testdata/includes",
|
||||
Target: "default",
|
||||
TrimSpace: true,
|
||||
Files: map[string]string{
|
||||
"main.txt": "main",
|
||||
"included.txt": "included",
|
||||
},
|
||||
}
|
||||
tt.Run(t)
|
||||
}
|
||||
|
1
testdata/includes/.gitignore
vendored
Normal file
1
testdata/includes/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.txt
|
14
testdata/includes/Taskfile.yml
vendored
Normal file
14
testdata/includes/Taskfile.yml
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
version: '2'
|
||||
|
||||
includes:
|
||||
included: ./included
|
||||
|
||||
tasks:
|
||||
default:
|
||||
cmds:
|
||||
- task: gen
|
||||
- task: included:gen
|
||||
|
||||
gen:
|
||||
cmds:
|
||||
- echo main > main.txt
|
6
testdata/includes/included/Taskfile.yml
vendored
Normal file
6
testdata/includes/included/Taskfile.yml
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
version: '2'
|
||||
|
||||
tasks:
|
||||
gen:
|
||||
cmds:
|
||||
- echo included > included.txt
|
Loading…
Reference in New Issue
Block a user