Skip to content

Tighten golden-test coverage: remove dead console fixtures and goldenize wasm all-engines#33248

Merged
pelikhan merged 2 commits into
mainfrom
copilot/go-fan-review-golden-module
May 19, 2026
Merged

Tighten golden-test coverage: remove dead console fixtures and goldenize wasm all-engines#33248
pelikhan merged 2 commits into
mainfrom
copilot/go-fan-review-golden-module

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 19, 2026

The charmbracelet/x/exp/golden usage audit identified stale console golden fixtures with no backing tests and weak assertions in TestWasmGolden_AllEngines that only checked for YAML section presence. This PR removes dead fixtures/comments and upgrades engine coverage to strict golden comparisons.

  • Console golden cleanup

    • Removed 15 orphaned .golden files under:
      • TestGolden_LayoutBoxRendering
      • TestGolden_LayoutComposition
      • TestGolden_LayoutEmphasisBox
      • TestGolden_TreeRendering
    • Removed corresponding stub comments in pkg/console/golden_test.go for non-existent tests.
  • Golden naming guardrail

    • Added a top-level note in pkg/console/golden_test.go to keep subtest names path-safe (no /) since golden.RequireEqual maps subtest names to testdata paths.
  • Wasm engine regression hardening

    • Updated TestWasmGolden_AllEngines to assert full normalized YAML via golden files instead of require.Contains(...).
    • Added per-engine fixtures in pkg/workflow/testdata/TestWasmGolden_AllEngines/:
      • copilot.golden
      • claude.golden
      • codex.golden
      • gemini.golden
      • pi.golden
  • Assertion change (example)

yamlOutput, err := compiler.CompileToYAML(wd, "workflow.md")
require.NoError(t, err, "%s engine compile failed", eng.name)

golden.RequireEqual(t, normalizeOutput(yamlOutput))

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Review Go module charmbracelet/x/exp/golden Tighten golden-test coverage: remove dead console fixtures and goldenize wasm all-engines May 19, 2026
Copilot AI requested a review from pelikhan May 19, 2026 09:25
@pelikhan pelikhan marked this pull request as ready for review May 19, 2026 09:34
Copilot AI review requested due to automatic review settings May 19, 2026 09:34
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 strengthens golden-test coverage in two ways: it deletes orphaned golden fixtures (and stale stub comments) under pkg/console/testdata whose tests no longer exist, and it replaces three weak require.Contains assertions in TestWasmGolden_AllEngines with strict golden.RequireEqual comparisons against newly added per-engine fixtures.

Changes:

  • Deleted 15 orphaned .golden files across four TestGolden_* subdirectories in pkg/console/testdata, plus the corresponding stub comments in pkg/console/golden_test.go, and added a guardrail comment about path-safe subtest names.
  • Replaced substring assertions in TestWasmGolden_AllEngines with a single golden.RequireEqual(t, normalizeOutput(yamlOutput)) call.
  • Added 5 new engine golden fixtures (copilot, claude, codex, gemini, pi) capturing full normalized YAML output.
Show a summary per file
File Description
pkg/workflow/wasm_golden_test.go Swap weak Contains checks for strict golden comparison.
pkg/workflow/testdata/TestWasmGolden_AllEngines/{copilot,claude,codex,gemini,pi}.golden New per-engine full-YAML golden fixtures backing the strict assertion.
pkg/console/golden_test.go Add path-safe naming note; remove stub comments for nonexistent tests.
pkg/console/testdata/TestGolden_TreeRendering/*.golden (5 files) Remove orphaned tree-rendering fixtures.
pkg/console/testdata/TestGolden_LayoutEmphasisBox/*.golden (4 files) Remove orphaned emphasis-box fixtures.
pkg/console/testdata/TestGolden_LayoutComposition/*.golden (3 files) Remove orphaned composition fixtures.
pkg/console/testdata/TestGolden_LayoutBoxRendering/*.golden (3 files) Remove orphaned layout-box fixtures.

Copilot's findings

Tip

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

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

@pelikhan pelikhan merged commit 6bc1d52 into main May 19, 2026
82 of 84 checks passed
@pelikhan pelikhan deleted the copilot/go-fan-review-golden-module branch May 19, 2026 09:45
@github-actions
Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Required

This PR introduces significant changes to core test/business-logic directories (>3000 new lines under pkg/) but does not link an Architecture Decision Record (ADR).

AI has analyzed the PR diff and generated a draft ADR to help you get started:

📄 Draft ADR: docs/adr/33248-strict-golden-comparison-and-orphan-fixture-pruning.md

The inferred decision is:

Switch TestWasmGolden_AllEngines from require.Contains substring assertions to strict golden.RequireEqual(t, normalizeOutput(yamlOutput)) comparisons against per-engine fixtures, and delete the 15 orphan .golden files under pkg/console/testdata/ whose backing tests no longer exist.

What to do next

  1. Review the draft ADR committed to your branch — it was generated from the PR diff and reflects what the AI could infer.
  2. Complete the missing sections — confirm or correct the Context, refine the rationale, list any alternatives you actually considered, and update the Consequences with your real assessment of the trade-offs.
  3. Promote the status from Draft to Proposed (or Accepted if appropriate) once it is reviewed.
  4. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-33248: Strict Golden Comparison for Engine Tests and Orphan Fixture Pruning

Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision.

Why ADRs Matter

ADRs create a searchable, permanent record of why the codebase looks the way it does. The shift from substring to strict golden comparison and the deletion of orphan fixtures are exactly the kind of test-strategy choices that future contributors (and your future self) will want context for when a golden diff blows up six months from now.


📋 Michael Nygard ADR Format Reference

An ADR must contain these four sections to be considered complete:

  • Context — What is the problem? What forces are at play?
  • Decision — What did you decide? Why?
  • Alternatives Considered — What else could have been done?
  • Consequences — What are the trade-offs (positive and negative)?

All ADRs are stored in docs/adr/ as Markdown files numbered by PR number (e.g., 33248-...md for this PR).

🔒 This PR cannot merge until the ADR is reviewed and linked in the PR body.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · ● 6.5M ·

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /tdd (test-driven development) and /zoom-out (broader architectural context) based on this test refactoring and cleanup PR.

Key Themes

✅ Excellent dead code removal — The 15 orphaned .golden files and their stub comments were technical debt from incomplete test implementation. This cleanup improves discoverability and removes confusion about which tests actually exist.

✅ Significant test hardening — Upgrading TestWasmGolden_AllEngines from require.Contains(...) to full golden comparison is a major quality improvement. The weak assertion pattern only checked for section presence, which could miss structural regressions. Golden files provide exact output verification.

⚠️ Missing test archaeology documentation — While the cleanup is correct, the PR doesn't explain why these fixtures were orphaned or whether the underlying functionality (LayoutBoxRendering, LayoutComposition, etc.) is actually tested elsewhere.

Positive Highlights

  • Path-safety guardrail — The comment in pkg/console/golden_test.go ("Keep subtest names path-safe...") is a valuable maintainability note for future test authors
  • Complete engine coverage — Adding per-engine golden files (copilot.golden, claude.golden, etc.) ensures all five engine compilation paths are regression-protected
  • Normalization consistency — The normalizeOutput() helper ensures golden comparisons are stable across environments

Suggestions

  1. [/tdd] Document what happened to the deleted test coverage in the commit message or PR body — were LayoutBoxRendering, LayoutComposition, etc. never implemented? Are they covered by other tests? This context helps reviewers understand whether functionality is now untested.

  2. [/zoom-out] Consider a follow-up task to audit whether the functionality represented by the deleted fixtures should have tests — the golden files suggested someone intended to test layout rendering, emphasis boxes, and tree rendering. If those code paths are untested, that's a gap.

Verdict

APPROVE — The cleanup is safe and the test hardening is valuable. The missing context is a minor documentation gap, not a blocker.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · ● 4.3M

require.Contains(t, yamlOutput, "name:", "%s engine output missing name", eng.name)
require.Contains(t, yamlOutput, "on:", "%s engine output missing on", eng.name)
require.Contains(t, yamlOutput, "jobs:", "%s engine output missing jobs", eng.name)
golden.RequireEqual(t, normalizeOutput(yamlOutput))
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.

[/tdd] Excellent upgrade from require.Contains(...) to golden.RequireEqual(...). The old assertion pattern:

require.Contains(t, yamlOutput, "name:")
require.Contains(t, yamlOutput, "jobs:")

Only verified that YAML sections existed, but couldn't catch structural regressions like incorrect nesting, missing fields, or value changes. Golden comparison catches all of these.

Impact: This change means all five engine compilation paths now have exact output verification, significantly reducing the risk of silent regressions.

"github.com/charmbracelet/x/exp/golden"
)

// Keep subtest names path-safe (no "/") since golden.RequireEqual maps them to testdata paths.
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.

[/tdd] Great guardrail comment. The constraint is subtle: golden.RequireEqual(t, ...) uses t.Name() to derive the fixture path, so subtest names like "layout/wide" would try to create testdata/TestFoo/layout/wide.golden, which breaks.

This is the kind of "pit of success" documentation that prevents future confusion.

@github-actions
Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

Test Quality Score: 95/100

🧪 Test quality analysis by Test Quality Sentinel · ● 7.4M ·

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

✅ Test Quality Sentinel: 95/100. Test quality is excellent — this PR upgrades weak require.Contains assertions to comprehensive golden file snapshot testing, significantly strengthening behavioral coverage for all 5 engine types.

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.

[go-fan] Go Module Review: charmbracelet/x/exp/golden

3 participants