Skip to content

Commit ac48ee0

Browse files
committed
fix panic for invalid task in cyclic dep detection
resolves partly #37
1 parent 06031ef commit ac48ee0

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

cyclic.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ func (e *Executor) CheckCyclicDep() error {
1313
defer delete(visits, name)
1414

1515
for _, d := range t.Deps {
16-
if err := checkCyclicDep(d.Task, e.Tasks[d.Task]); err != nil {
16+
// FIXME: ignoring by now. should return an error instead?
17+
task, ok := e.Tasks[d.Task]
18+
if !ok {
19+
continue
20+
}
21+
if err := checkCyclicDep(d.Task, task); err != nil {
1722
return err
1823
}
1924
}

cyclic_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,22 @@ func TestCyclicDepCheck(t *testing.T) {
3535
}
3636

3737
assert.NoError(t, isNotCyclic.CheckCyclicDep())
38+
39+
inexixtentTask := &task.Executor{
40+
Tasks: task.Tasks{
41+
"task-a": &task.Task{
42+
Deps: []*task.Dep{&task.Dep{Task: "invalid-task"}},
43+
},
44+
},
45+
}
46+
47+
// FIXME: by now Task should ignore non existent tasks
48+
// in the future we should improve the detection of
49+
// tasks called with interpolation?
50+
// task:
51+
// deps:
52+
// - task: "task{{.VARIABLE}}"
53+
// vars:
54+
// VARIABLE: something
55+
assert.NoError(t, inexixtentTask.CheckCyclicDep())
3856
}

0 commit comments

Comments
 (0)