diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2024-07-05 12:20:26 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-07-08 07:01:24 +0000 |
| commit | b0d6aa6df955f9a20d9ef61bc3e781d9ce135c6c (patch) | |
| tree | e4b1367cbe1ea24f20f37366ffe68ee8e6148bd6 /pkg/runtest | |
| parent | b1dad173ed7da74feb273f0397de0f4a4ff759e7 (diff) | |
pkg/runtest: accept Context as a parameter
The cancellable context will let us abort runtest early in case of
problems.
Diffstat (limited to 'pkg/runtest')
| -rw-r--r-- | pkg/runtest/run.go | 4 | ||||
| -rw-r--r-- | pkg/runtest/run_test.go | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/pkg/runtest/run.go b/pkg/runtest/run.go index 50af943e0..110ec15d4 100644 --- a/pkg/runtest/run.go +++ b/pkg/runtest/run.go @@ -67,7 +67,7 @@ func (ctx *Context) log(msg string, args ...interface{}) { ctx.LogFunc(fmt.Sprintf(msg, args...)) } -func (ctx *Context) Run() error { +func (ctx *Context) Run(waitCtx context.Context) error { ctx.buildSem = make(chan bool, runtime.GOMAXPROCS(0)) ctx.executor = queue.DynamicOrder() ctx.generatePrograms() @@ -84,7 +84,7 @@ func (ctx *Context) Run() error { result = fmt.Sprintf("SKIP (%v)", req.skip) verbose = true } else { - req.Request.Wait(context.Background()) + req.Request.Wait(waitCtx) if req.err != nil { fail++ result = fmt.Sprintf("FAIL: %v", diff --git a/pkg/runtest/run_test.go b/pkg/runtest/run_test.go index 19619ee73..acf59c93d 100644 --- a/pkg/runtest/run_test.go +++ b/pkg/runtest/run_test.go @@ -85,7 +85,7 @@ func test(t *testing.T, sysTarget *targets.Target) { Verbose: true, Debug: *flagDebug, } - startRPCServer(t, target, executor, "", ctx, nil, nil, func(features flatrpc.Feature) { + waitCtx := startRPCServer(t, target, executor, "", ctx, nil, nil, func(features flatrpc.Feature) { // Features we expect to be enabled on the test OS. // All sandboxes except for none are not implemented, coverage is not returned, // and setup for few features is failing specifically to test feature detection. @@ -113,7 +113,7 @@ func test(t *testing.T, sysTarget *targets.Target) { if t.Failed() { return } - if err := ctx.Run(); err != nil { + if err := ctx.Run(waitCtx); err != nil { t.Fatal(err) } } |
