Skip to content

Commit

Permalink
do not print parent task is parent task is finished.
Browse files Browse the repository at this point in the history
  • Loading branch information
syifan committed Apr 26, 2024
1 parent 898b9e4 commit ddfee9a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tracing/backtracetracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,10 @@ func (t *BackTraceTracer) DumpBackTrace(task Task) {
return
}

t.DumpBackTrace(t.tracingTasks[task.ParentID])
parentTask, ok := t.tracingTasks[task.ParentID]
if !ok {
return
}

t.DumpBackTrace(parentTask)
}
13 changes: 13 additions & 0 deletions tracing/backtracetracer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,17 @@ var _ = Describe("BackTraceTracer", func() {

t.DumpBackTrace(Task{ID: "3", ParentID: "2"})
})

It("should print three tasks", func() {
t.StartTask(Task{ID: "1"})
t.StartTask(Task{ID: "2", ParentID: "1"})
t.StartTask(Task{ID: "3", ParentID: "2"})

t.EndTask(Task{ID: "2", ParentID: "1"})

mockTaskPrinter.EXPECT().
Print(Task{ID: "3", ParentID: "2"})

t.DumpBackTrace(Task{ID: "3", ParentID: "2"})
})
})

0 comments on commit ddfee9a

Please sign in to comment.