diff --git a/task_test.go b/task_test.go index 9602a6c0..bac7e33d 100644 --- a/task_test.go +++ b/task_test.go @@ -838,6 +838,20 @@ func TestIncorrectVersionIncludes(t *testing.T) { assert.EqualError(t, e.Setup(), expectedError) } +func TestIncludesIncorrect(t *testing.T) { + const dir = "testdata/includes_incorrect" + + var buff bytes.Buffer + e := task.Executor{ + Dir: dir, + Stdout: &buff, + Stderr: &buff, + Silent: true, + } + + assert.Error(t, e.Setup()) +} + func TestIncludesEmptyMain(t *testing.T) { tt := fileContentTest{ Dir: "testdata/includes_empty", diff --git a/taskfile/read/taskfile.go b/taskfile/read/taskfile.go index 220b66c4..8de573dd 100644 --- a/taskfile/read/taskfile.go +++ b/taskfile/read/taskfile.go @@ -188,7 +188,10 @@ func readTaskfile(file string) (*taskfile.Taskfile, error) { return nil, err } var t taskfile.Taskfile - return &t, yaml.NewDecoder(f).Decode(&t) + if err := yaml.NewDecoder(f).Decode(&t); err != nil { + return nil, fmt.Errorf("%s: %w", file, err) + } + return &t, nil } func exists(path string) (string, error) { diff --git a/testdata/includes_incorrect/Taskfile.yml b/testdata/includes_incorrect/Taskfile.yml new file mode 100644 index 00000000..5d9ee884 --- /dev/null +++ b/testdata/includes_incorrect/Taskfile.yml @@ -0,0 +1,4 @@ +version: '3' + +includes: + included: incomplete.yml diff --git a/testdata/includes_incorrect/incomplete.yml b/testdata/includes_incorrect/incomplete.yml new file mode 100644 index 00000000..d5221276 --- /dev/null +++ b/testdata/includes_incorrect/incomplete.yml @@ -0,0 +1,4 @@ +version: '3' + +name: + 'test