1
0
mirror of https://github.com/go-task/task.git synced 2025-11-23 22:24:45 +02:00

Merge pull request #573 from masaushi/bugfix/issue-534-seg-fault-on-empty-command

Fix segmentation fault on nil slice element for issue #534
This commit is contained in:
Andrey Nering
2021-09-25 09:46:47 -03:00
committed by GitHub
5 changed files with 74 additions and 12 deletions

View File

@@ -1025,3 +1025,29 @@ func TestRunOnlyRunsJobsHashOnce(t *testing.T) {
}
tt.Run(t)
}
func TestIgnoreNilElements(t *testing.T) {
tests := []struct {
name string
dir string
}{
{"nil cmd", "testdata/ignore_nil_elements/cmds"},
{"nil dep", "testdata/ignore_nil_elements/deps"},
{"nil precondition", "testdata/ignore_nil_elements/preconditions"},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
var buff bytes.Buffer
e := task.Executor{
Dir: test.dir,
Stdout: &buff,
Stderr: &buff,
Silent: true,
}
assert.NoError(t, e.Setup())
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "default"}))
assert.Equal(t, "string-slice-1\n", buff.String())
})
}
}