diff --git a/task_test.go b/task_test.go index 9fc018b1..f51e0635 100644 --- a/task_test.go +++ b/task_test.go @@ -891,6 +891,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 7c6f8685..9035f58b 100644 --- a/taskfile/read/taskfile.go +++ b/taskfile/read/taskfile.go @@ -189,7 +189,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