Skip to content

refactor: extract shared parameterised test factory for log sub-commands#2563

Merged
lpcox merged 2 commits intomainfrom
copilot/refactor-logs-test-files
May 5, 2026
Merged

refactor: extract shared parameterised test factory for log sub-commands#2563
lpcox merged 2 commits intomainfrom
copilot/refactor-logs-test-files

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 5, 2026

logs-stats.test.ts and logs-summary.test.ts were structurally near-identical — ~160 lines duplicated across 6 clone pairs, differing only in the command under test and its default format.

Changes

  • test-helpers.test-utils.ts — adds createLogCommandTests<TOptions>(): a generic factory that registers the 6 common test cases (source discovery, explicit source, no-source error, invalid-source error, aggregation error, format forwarding) under their own describe block. Accepts commandName, runCommand, defaultFormat, and a makeOptions factory for typed option construction.

  • logs-stats.test.ts — reduced to a createLogCommandTests(...) call + one stats-specific describe covering the info-log suppression behaviour (logs for pretty/markdown, suppresses for json).

  • logs-summary.test.ts — reduced to a createLogCommandTests(...) call + one describe covering the two summary-specific cases: markdown-default assertion and stricter info-log suppression (only pretty logs; markdown and json are both silent).

// Each test file is now just:
createLogCommandTests<StatsCommandOptions>(
  'stats',
  statsCommand,
  'pretty',
  (overrides?) => ({ format: 'pretty', ...overrides } as StatsCommandOptions),
);

Command-specific edge cases remain in their own describe blocks. All 15 original tests continue to pass.

Copilot AI changed the title [WIP] Refactor near-duplicate test files for logs-stats and logs-summary refactor: extract shared parameterised test factory for log sub-commands May 5, 2026
Copilot finished work on behalf of lpcox May 5, 2026 14:04
Copilot AI requested a review from lpcox May 5, 2026 14:04
@lpcox lpcox marked this pull request as ready for review May 5, 2026 18:29
@lpcox lpcox requested a review from Mossaka as a code owner May 5, 2026 18:29
Copilot AI review requested due to automatic review settings May 5, 2026 18:29
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 86.45% 86.72% 📈 +0.27%
Statements 86.38% 86.64% 📈 +0.26%
Functions 90.61% 90.78% 📈 +0.17%
Branches 79.23% 79.27% 📈 +0.04%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/container-lifecycle.ts 86.1% → 87.2% (+1.09%) 86.3% → 87.4% (+1.08%)

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the duplicated logs-stats and logs-summary unit tests by extracting their shared source-selection / formatting assertions into a reusable test factory. It fits the codebase’s existing command-test structure by keeping command-specific behavior tests local while centralizing the common log-command contract.

Changes:

  • Added createLogCommandTests<TOptions>() in test-helpers.test-utils.ts to register the shared test cases for log subcommands.
  • Replaced duplicated shared tests in logs-stats.test.ts with a single factory call plus the stats-specific logging-behavior test.
  • Replaced duplicated shared tests in logs-summary.test.ts with a single factory call plus the summary-specific markdown/logging tests.
Show a summary per file
File Description
src/commands/test-helpers.test-utils.ts Adds the shared parameterized Jest test factory for common log-command behaviors.
src/commands/logs-summary.test.ts Switches summary tests to the shared factory and retains summary-specific assertions.
src/commands/logs-stats.test.ts Switches stats tests to the shared factory and retains stats-specific logging assertions.

Copilot's findings

Tip

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

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

🔬 Smoke Test Results

Test Result
GitHub MCP connectivity
GitHub.com HTTP ⚠️ N/A (template vars not expanded)
File write/read ⚠️ N/A (template vars not expanded)

PR: "refactor: extract shared parameterised test factory for log sub-commands" — author @Copilot, assignees @lpcox @Copilot

Overall: PARTIAL — MCP ✅, pre-computed test data unavailable (workflow template substitution did not occur).

📰 BREAKING: Report filed by Smoke Copilot

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Smoke Test: Copilot BYOK (Offline Mode)

Test Result
1. GitHub MCP ✅ Listed PRs (latest closed: #2580)
2. GitHub.com connectivity ⚠️ Pre-step data not interpolated
3. File write/read ❌ File not found (pre-step outputs missing)
4. BYOK inference (this response) ✅ Agent responding via api-proxy → api.githubcopilot.com

Running in BYOK offline mode (COPILOT_OFFLINE=true) via api-proxy → api.githubcopilot.com

PR: "refactor: extract shared parameterised test factory for log sub-commands" by @Copilot · Assignees: @lpcox, @Copilot

Overall: PARTIAL — BYOK inference ✅, pre-step smoke data was not interpolated (template expressions unevaluated).

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

🧪 Chroot Version Comparison Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3
Node.js v24.14.1 v20.20.2
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

github-actions Bot commented May 5, 2026

Smoke Test Results

  • Redis PING: ❌ (timeout — no response)
  • PostgreSQL pg_isready: ❌ (no response)
  • PostgreSQL SELECT 1: ❌ (timeout — no response)

Overall: FAILhost.docker.internal is not reachable from this runner environment. Service containers may not be running or the hostname is not resolvable.

🔌 Service connectivity validated by Smoke Services

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

api-proxy: inject X-Initiator: agent default on all Copilot-bound requests to prevent billing inflation
fix: one-shot-token.so fails to load on musl/Alpine hosts (ARC runners)
GitHub MCP ❌
safeinputs-gh ❌
Playwright ✅
Tavily ❌
File write/read ✅
Discussion comment ✅
Build ✅
Overall: FAIL

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

github-actions Bot commented May 5, 2026

🏗️ 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

Note (Java): Maven could not create the default local repository at ~/.m2/repository (permission denied — owned by root). Tests were run successfully using -Dmaven.repo.local=/tmp/gh-aw/agent/m2-repo as a workaround.

Generated by Build Test Suite for issue #2563 · ● 667.4K ·

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Smoke Test Results ✅ PASS

Recent merged PRs (last 2):

  • api-proxy: inject X-Initiator: agent default on all Copilot-bound requests to prevent billing inflation
  • fix: one-shot-token.so fails to load on musl/Alpine hosts (ARC runners)

Tests:

  • ✅ GitHub MCP: Retrieved last 2 merged PRs
  • ✅ Playwright: github.com title verified
  • ✅ File Writing: Created smoke test file
  • ✅ Bash Tool: File verified successfully

💥 [THE END] — Illustrated by Smoke Claude

@lpcox lpcox merged commit 2614be7 into main May 5, 2026
69 of 73 checks passed
@lpcox lpcox deleted the copilot/refactor-logs-test-files branch May 5, 2026 20:24
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.

[Duplicate Code] Near-duplicate test files for logs-stats and logs-summary commands

3 participants