1
0
mirror of https://github.com/go-task/task.git synced 2025-07-13 01:30:33 +02:00

fix panic for invalid task in cyclic dep detection

resolves partly #37
This commit is contained in:
Andrey Nering
2017-07-08 10:25:15 -03:00
parent 06031efc09
commit ac48ee066e
2 changed files with 24 additions and 1 deletions

View File

@ -13,7 +13,12 @@ func (e *Executor) CheckCyclicDep() error {
defer delete(visits, name) defer delete(visits, name)
for _, d := range t.Deps { for _, d := range t.Deps {
if err := checkCyclicDep(d.Task, e.Tasks[d.Task]); err != nil { // FIXME: ignoring by now. should return an error instead?
task, ok := e.Tasks[d.Task]
if !ok {
continue
}
if err := checkCyclicDep(d.Task, task); err != nil {
return err return err
} }
} }

View File

@ -35,4 +35,22 @@ func TestCyclicDepCheck(t *testing.T) {
} }
assert.NoError(t, isNotCyclic.CheckCyclicDep()) assert.NoError(t, isNotCyclic.CheckCyclicDep())
inexixtentTask := &task.Executor{
Tasks: task.Tasks{
"task-a": &task.Task{
Deps: []*task.Dep{&task.Dep{Task: "invalid-task"}},
},
},
}
// FIXME: by now Task should ignore non existent tasks
// in the future we should improve the detection of
// tasks called with interpolation?
// task:
// deps:
// - task: "task{{.VARIABLE}}"
// vars:
// VARIABLE: something
assert.NoError(t, inexixtentTask.CheckCyclicDep())
} }