Skip to content

refactor(tests): deduplicate signal-handler tests with shared helper and it.each#5660

Merged
lpcox merged 2 commits into
mainfrom
copilot/duplicate-code-signal-handler-tests
Jun 29, 2026
Merged

refactor(tests): deduplicate signal-handler tests with shared helper and it.each#5660
lpcox merged 2 commits into
mainfrom
copilot/duplicate-code-signal-handler-tests

Conversation

Copilot AI commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

SIGINT and SIGTERM signal-handler tests had identical mock setup, dependency wiring, handler dispatch, and promise-flushing repeated across five test cases — any change to cleanup behaviour required updating multiple nearly-identical blocks.

Changes

  • runSignalScenario helper — inner async function that accepts { signal, containersStarted, keepContainers, fastKillRejects? }, wires up mocks + deps, calls registerSignalHandlers, dispatches the signal, flushes promises, and returns { fastKill, performCleanup } for assertions.
  • it.each for paired SIGINT/SIGTERM cases — two duplicate test pairs collapsed into parameterised tests:
    • fast-kills agent container on %s when containers are started and keepContainers is false
    • swallows errors thrown during %s handling
  • Remaining unique tests (registers handlers, skips fast-kill when containers not started, skips fast-kill when keepContainers is true) rewritten to call runSignalScenario, eliminating inline boilerplate.
it.each([
  ['SIGINT', 130],
  ['SIGTERM', 143],
] as const)(
  'fast-kills agent container on %s when containers are started and keepContainers is false',
  async (signal, exitCode) => {
    const { fastKill, performCleanup } = await runSignalScenario({
      signal, containersStarted: true, keepContainers: false,
    });
    expect(fastKill).toHaveBeenCalled();
    expect(performCleanup).toHaveBeenCalledWith(signal);
    expect(processExitSpy).toHaveBeenCalledWith(exitCode);
  }
);

Net: ~60 lines removed, same coverage, single place to update when cleanup semantics change.

Copilot AI changed the title [WIP] Refactor signal handler tests to eliminate duplicate code refactor(tests): deduplicate signal-handler tests with shared helper and it.each Jun 28, 2026
Copilot finished work on behalf of lpcox June 28, 2026 23:35
Copilot AI requested a review from lpcox June 28, 2026 23:35
@lpcox lpcox marked this pull request as ready for review June 28, 2026 23:39
Copilot AI review requested due to automatic review settings June 28, 2026 23:39

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

Refactors registerSignalHandlers unit tests to remove repeated per-signal boilerplate by introducing a shared runSignalScenario helper and parameterizing paired SIGINT/SIGTERM test cases. This keeps the test behavior coverage the same while making future signal-cleanup semantics changes easier to update in one place.

Changes:

  • Introduces runSignalScenario to centralize mock wiring, handler registration, signal dispatch, and promise flushing.
  • Collapses duplicated SIGINT/SIGTERM assertions into it.each-parameterized tests for fast-kill behavior and error-swallowing behavior.
  • Updates remaining unique tests to use the shared helper while preserving their intent.
Show a summary per file
File Description
src/commands/signal-handler.test.ts Deduplicates SIGINT/SIGTERM handler tests using a shared scenario helper and it.each parameterization.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Low

@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@copilot Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Contribution Check completed successfully!

Contribution check complete for PR #5660: the test-only refactor follows the applicable CONTRIBUTING.md guidelines, with no important missing items requiring a PR comment.

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Smoke Gemini completed. All facets verified. 💎

Smoke test completed with partial success (File/Bash passed, Network/MCP failed).

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (api-key) completed. Copilot AOAI BYOK (api-key) mode operational. 🔓

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (Entra) completed. Copilot AOAI BYOK (Entra) mode operational. 🔓

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Security Guard has started processing this pull request

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Build Test Suite completed successfully!

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude passed

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 98.16% 98.20% 📈 +0.04%
Statements 98.10% 98.13% 📈 +0.03%
Functions 99.54% 99.54% ➡️ +0.00%
Branches 94.14% 94.14% ➡️ +0.00%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/workdir-setup.ts 92.7% → 94.5% (+1.82%) 92.7% → 94.5% (+1.82%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

@github-actions github-actions Bot mentioned this pull request Jun 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Direct) Results

MCP Connectivity — Listed 2 recent merged PRs from gh-aw-firewall
GitHub.com Connectivity — HTTP 200
File Write/Read — Smoke test file created and readable
BYOK Inference Path — Direct mode active (agent → api-proxy → api.githubcopilot.com)

Status: PASS | Mode: Direct BYOK via api-proxy
Assignees: @lpcox, @Copilot

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions

Copy link
Copy Markdown
Contributor

🔥 Smoke Test — Auth mode: PAT (COPILOT_GITHUB_TOKEN)

Test Result
GitHub MCP ✅ PR #5653 listed
GitHub.com HTTP ✅ 200
File write/read ❌ template vars not substituted — path unknown

Overall: FAIL

@lpcox @Copilot — file test could not be verified; smoke-data outputs were not passed to this step.

🔑 PAT report filed by Smoke Copilot PAT

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Claude Engine Validation

Check Status
API ✅ PASS
GH ✅ PASS
File ✅ PASS

Overall result: PASS

Generated by Smoke Claude for #5660 · 58.4 AIC · ⊞ 6.1K ·

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Smoke Test Results

PR: refactor(tests): deduplicate signal-handler tests with shared helper and it.each
Author: @Copilot | Assignees: @lpcox, @Copilot

Test Result
GitHub MCP connectivity
HTTP github.com ⚠️ pre-step data not injected
File write/read ⚠️ pre-step data not injected

Overall: PARTIAL — MCP verified ✅; pre-step template variables unexpanded (workflow infra issue, not engine failure)

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

Copy link
Copy Markdown
Contributor
  • fix: handle EACCES during chroot-home cleanup in rootless Docker — ✅
  • docs(runner-doctor): add C7 failure mode for DIFC probe on *.ghe.com — ✅
  • GitHub CLI query — ✅
  • Browser title check — ✅
  • File write/readback — ✅
  • Build (npm ci && npm run build) — ✅
    Overall status: PASS

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • registry.npmjs.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "registry.npmjs.org"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex

@github-actions

Copy link
Copy Markdown
Contributor

@lpcox @Copilot
refactor(tests): deduplicate signal-handler tests with shared helper and it.each — ✅ MCP tool ✅ github.com ✅ file IO ✅ BYOK inference
Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw)
Overall: PASS

🔑 BYOK (AOAI api-key) report filed by Smoke Copilot BYOK AOAI (api-key)

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smoke Test: API Proxy OpenTelemetry Tracing

Scenario Result Notes
1. Module Loading otel.js loads cleanly; exports startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled + internals. isEnabled()true (FileSpanExporter fallback active when no OTLP endpoint set).
2. Test Suite otel.test.js: 39 tests passed, 0 failed (1.9 s). Full coverage of split modules, span creation, token attributes, parent context, exporters, and graceful shutdown.
3. Env Var Forwarding src/services/api-proxy-env-config.ts forwards all required OTEL vars: GH_AW_OTLP_ENDPOINTS, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS, GITHUB_AW_OTEL_TRACE_ID, GITHUB_AW_OTEL_PARENT_SPAN_ID, OTEL_SERVICE_NAME.
4. Token Tracker Integration token-tracker-http.js exposes onUsage callback (line 283/324) and onSpanEnd callback as the OTEL hook points; callers wire setTokenAttributes / endSpan through these.
5. OTEL Diagnostics No OTLP endpoint configured in this run → spans exported to /var/log/api-proxy/otel.jsonl (local fallback). No unexpected errors. Graceful degradation working as designed.

All 5 scenarios passed. OTEL tracing integration is functional.

📡 OTel tracing validated by Smoke OTel Tracing

@github-actions

Copy link
Copy Markdown
Contributor

@lpcox

✅ GitHub MCP Testing
✅ GitHub.com Connectivity
✅ File Write/Read Test
✅ BYOK Inference Test

Running in direct BYOK mode (AWF_AUTH_TYPE=github-oidc + AWF_AUTH_AZURE_* + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw) authenticated via Microsoft Entra

Overall: PASS

🪪 BYOK (AOAI Entra) report filed by Smoke Copilot BYOK AOAI (Entra)

@github-actions

Copy link
Copy Markdown
Contributor

Chroot Version Comparison Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3
Node.js v24.17.0 v22.23.0
Go go1.22.12 go1.22.12

Overall: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot environments.

Tested by Smoke Chroot

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results (Gemini)

  • GitHub MCP Testing: ❌ (Tools not found)
  • GitHub.com Connectivity: ❌ (Status 000/400)
  • File Writing Testing: ✅
  • Bash Tool Testing: ✅

Overall status: FAIL

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • localhost

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "localhost"

See Network Configuration for more information.

💎 Faceted by Smoke Gemini

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia 1/1 passed ✅ PASS
Bun hono 1/1 passed ✅ PASS
C++ fmt N/A ✅ PASS
C++ json N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world N/A ✅ PASS
.NET json-parse N/A ✅ PASS
Go color 1/1 passed ✅ PASS
Go env 1/1 passed ✅ PASS
Go uuid 1/1 passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx All passed ✅ PASS
Node.js execa All passed ✅ PASS
Node.js p-limit All passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Generated by Build Test Suite for #5660 · 49.3 AIC · ⊞ 7.8K ·

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Services Connectivity

Check Result
Redis PING ❌ (no response / timeout)
PostgreSQL pg_isready no response
PostgreSQL SELECT 1 ❌ (no response / timeout)

Overall: FAILhost.docker.internal is not reachable from this runner environment. Service containers appear unavailable.

🔌 Service connectivity validated by Smoke Services

@lpcox lpcox merged commit 06f3314 into main Jun 29, 2026
88 of 91 checks passed
@lpcox lpcox deleted the copilot/duplicate-code-signal-handler-tests branch June 29, 2026 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants