mirror of
https://github.com/go-task/task.git
synced 2025-11-23 22:24:45 +02:00
Fix panic for empty tasks
Closes #338 Closes #362 Co-authored-by: Bharath Kumar <shettybharath4@gmail.com>
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
- Fix panic when you have empty tasks in your Taskfile
|
||||||
|
([#338](https://github.com/go-task/task/issues/338), [#362](https://github.com/go-task/task/pull/362)).
|
||||||
|
|
||||||
## v3.0.0
|
## v3.0.0
|
||||||
|
|
||||||
- On `v3`, all CLI variables will be considered global variables
|
- On `v3`, all CLI variables will be considered global variables
|
||||||
|
|||||||
10
task_test.go
10
task_test.go
@@ -56,6 +56,16 @@ func (fct fileContentTest) Run(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestEmptyTask(t *testing.T) {
|
||||||
|
e := &task.Executor{
|
||||||
|
Dir: "testdata/empty_task",
|
||||||
|
Stdout: ioutil.Discard,
|
||||||
|
Stderr: ioutil.Discard,
|
||||||
|
}
|
||||||
|
assert.NoError(t, e.Setup(), "e.Setup()")
|
||||||
|
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "default"}))
|
||||||
|
}
|
||||||
|
|
||||||
func TestEnv(t *testing.T) {
|
func TestEnv(t *testing.T) {
|
||||||
tt := fileContentTest{
|
tt := fileContentTest{
|
||||||
Dir: "testdata/env",
|
Dir: "testdata/env",
|
||||||
|
|||||||
@@ -119,6 +119,10 @@ func Taskfile(dir string, entrypoint string) (*taskfile.Taskfile, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for name, task := range t.Tasks {
|
for name, task := range t.Tasks {
|
||||||
|
if task == nil {
|
||||||
|
task = &taskfile.Task{}
|
||||||
|
t.Tasks[name] = task
|
||||||
|
}
|
||||||
task.Task = name
|
task.Task = name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
testdata/empty_task/Taskfile.yml
vendored
Normal file
4
testdata/empty_task/Taskfile.yml
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
default:
|
||||||
Reference in New Issue
Block a user