Atlas › Test

TestGoroCancelParentCtx

Exact test identity: go.temporal.io/server/common/goro/TestGoroCancelParentCtx

Package
go.temporal.io/server/common/goro
Suite / test hierarchy
TestGoroCancelParentCtx
Test
TestGoroCancelParentCtx
Introduced at
TestGoroParentTimeout, TestGoroCancelParentCtx Frontier kind: Test frontier
Covered ranges
8
Covered lines
31
Covered files
2

Co-introduced tests

1 other test enter at the same concept.

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/common/goro/goro.go 24 covered LOC · 7 ranges

Open complete file

22 // the goroutine starts, which makes it possible for the goroutine to call
23 // Done() on itself (maybe indirectly) without a race condition.
24 > func NewHandle(ctx context.Context) *Handle { goro.go
25 > ctx, cancel := context.WithCancel(ctx)
26 > return &Handle{
27 > context: ctx,
28 > cancel: cancel,
29 > done: make(chan struct{}),
30 > }
31 > }
32
33 // Go launches the supplied function in its own goroutine. Go should be called
34 // exactly once on each *Handle.
35 > func (h *Handle) Go(f func(context.Context) error) *Handle { goro.go
36 > go func() {
37 > // use defer here so that the channel is closed even if the func calls
38 > // runtime.Goexit()
39 > defer close(h.done)
40 > if err := f(h.context); err != nil {
41 > h.err.Store(err) goro.go
42 > }
43 }()
44 > return h goro.go
45 }
46
49 // the Done() channel closing is the time taken by the goroutine to shut itself
50 // down.
51 > func (h *Handle) Done() <-chan struct{} { goro.go
52 > return h.done
53 > }
54
55 // Cancel requests that this goroutine stop by cancelling the associated context
63 // never any error (i.e. this function returns nil) while the goroutine is
64 // running.
65 > func (h *Handle) Err() error { goro.go
66 > v := h.err.Load()
67 > if v == nil {
68 return nil
69 }
70 > return v.(error) goro.go
71 }
go.temporal.io/server/common/testing/parallelsuite/suite.go 7 covered LOC · 1 range

Open complete file

228 var inheritedMethods map[string]bool
229
230 > func init() { suite.go
231 > type ds struct{ Suite[*ds] }
232 > ptrType := reflect.TypeFor[*ds]()
233 > inheritedMethods = make(map[string]bool, ptrType.NumMethod())
234 > for method := range ptrType.Methods() {
235 > inheritedMethods[method.Name] = true
236 > }
237 }
238