1
0
mirror of https://github.com/go-task/task.git synced 2025-02-09 13:47:06 +02:00

Merge pull request #887 from ronaudinho/fix/yaml-error-msg

Add file path to YAML error message
This commit is contained in:
Andrey Nering 2022-10-14 19:36:58 -03:00 committed by GitHub
commit 80b417c4ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 1 deletions

View File

@ -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",

View File

@ -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) {

View File

@ -0,0 +1,4 @@
version: '3'
includes:
included: incomplete.yml

View File

@ -0,0 +1,4 @@
version: '3'
name:
'test