Skip to content

fix: respect signal cancellation in waza run#279

Merged
github-actions[bot] merged 3 commits into
mainfrom
spboyer/fix-issue-23-signal-cancel
May 23, 2026
Merged

fix: respect signal cancellation in waza run#279
github-actions[bot] merged 3 commits into
mainfrom
spboyer/fix-issue-23-signal-cancel

Conversation

@spboyer

@spboyer spboyer commented May 22, 2026

Copy link
Copy Markdown
Member

Closes #23

Summary

  • Use a cancellable signal.NotifyContext for the long-running benchmark path in waza run.
  • Add a narrow regression test that proves the run path observes signal cancellation via a fake benchmark runner.

Validation

  • go test ./cmd/waza -run TestRunCommand_CancelsOnInterrupt -count=1
  • make build
  • make test currently fails in web/node_modules/flatted/golang/pkg/flatted after npm ci (unrelated repo issue)

Documentation impact

  • No docs update needed; this is an internal cancellation behavior change only.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 22, 2026 20:49
@github-actions github-actions Bot enabled auto-merge (squash) May 22, 2026 20:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates waza run to propagate OS signal cancellation into the long-running benchmark execution so Ctrl+C / termination signals can stop work promptly, and adds a regression test to verify cancellation is observed by the run path.

Changes:

  • Wrap the benchmark execution context in signal.NotifyContext(cmd.Context(), os.Interrupt, syscall.SIGTERM) and pass it into RunBenchmark.
  • Add an injectable newBenchmarkRunner (via a small benchmarkRunner interface) to allow test substitution.
  • Add a subprocess-based regression test that sends a signal and asserts the benchmark path exits via context cancellation.
Show a summary per file
File Description
cmd/waza/cmd_run.go Introduces a cancellable signal-aware context for RunBenchmark and adds a test hook for runner construction.
cmd/waza/cmd_run_test.go Resets the new runner-construction global in resetRunGlobals to avoid cross-test leakage.
cmd/waza/cmd_run_signal_test.go Adds a regression test that validates signal-driven cancellation behavior using a blocking fake runner.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 2

Comment thread cmd/waza/cmd_run_signal_test.go
Comment thread cmd/waza/cmd_run_signal_test.go Outdated
spboyer and others added 2 commits May 22, 2026 17:08
- Use context.Background() when cmd is nil (test path) to prevent
  nil pointer dereference in signal.NotifyContext
- Skip TestRunCommand_CancelsOnInterrupt on Windows where
  Process.Signal(SIGTERM) is not supported

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 23, 2026 00:45
@github-actions github-actions Bot merged commit 3be9dba into main May 23, 2026
7 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Comment on lines +69 to +81
cmd := exec.CommandContext(ctx, os.Args[0], "-test.run=TestRunCommand_SignalCancelsBenchmarkHelperProcess")
cmd.Env = append(os.Environ(),
runSignalHelperEnv+"=1",
runSignalSpecEnv+"="+specPath,
)
var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr

require.NoError(t, cmd.Start())
time.Sleep(200 * time.Millisecond)
require.NoError(t, cmd.Process.Signal(syscall.SIGTERM))
require.NoError(t, cmd.Wait(), "run should exit cleanly after SIGTERM; stdout=%s stderr=%s", stdout.String(), stderr.String())
@spboyer spboyer mentioned this pull request May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Performance Review

3 participants