Skip to content

fix(cli): anchor test-report testPaths to the spec folder deterministically#23

Merged
protonspy merged 1 commit into
mainfrom
feat/test-report-spec-paths
Jun 8, 2026
Merged

fix(cli): anchor test-report testPaths to the spec folder deterministically#23
protonspy merged 1 commit into
mainfrom
feat/test-report-spec-paths

Conversation

@protonspy

Copy link
Copy Markdown
Owner

Summary

csdd spec test-report populated test-report.json's testPaths from the
workspace-relative paths of whichever JUnit/coverage artifacts were parsed or
auto-discovered (e.g. coverage.out, tests/junit.xml). That value was
non-deterministic — it drifted with --path and where the runner dropped files,
and could point outside the spec.

This change makes testPaths deterministically point at the spec's own folder:
exactly one entry specs/<feature>/ (forward-slash, trailing slash), set once
after the nothing-to-record guard, independent of artifact locations and of how
the metrics were gathered (--run discovery, --junit/--coverage, or explicit
counts). The now-orphaned appendUnique helper is removed; the stale TestPaths
doc comment in internal/session/reports.go is corrected.

Spec: specs/test-report-spec-paths/ (requirements → design → tasks all approved; csdd spec validate green).

Changes

  • internal/cli/spec.go — set rep.TestPaths = []string{filepath.ToSlash(workspace.Relative(r, sdir)) + "/"}; drop the two appendUnique(rep.TestPaths, …Source) calls and the orphaned helper.
  • internal/cli/test_report_test.go — assert the exact spec-folder value across --run, --junit/--coverage, and explicit-count origins; negative assertions that no artifact filename leaks.
  • internal/session/reports.go — correct the now-false TestPaths doc comment (field/type unchanged).

Verification

- make check (gofmt + go vet + go test -race ./...)   ✅  (internal/cli 85.5%)
- csdd spec test-report (dogfood, rebuilt binary)      ✅  testPaths == ["specs/test-report-spec-paths/"], cov 81.2%
- code-reviewer sub-agent                              ✅  APPROVE, 0 Blockers

Risks

  • Behavior change to a recorded field: any consumer that read testPaths expecting artifact file paths now gets the spec directory. The only in-repo consumer is the csdd web dashboard, which renders it as a string[] — unaffected (a one-element array is still valid). test-report.json is regenerated on the next run.

🤖 Generated with Claude Code

…ically

`csdd spec test-report` recorded `testPaths` from the workspace-relative paths
of whichever JUnit/coverage artifacts were parsed or auto-discovered, so the
value drifted with `--path` and the runner's output location and could point
outside the spec. Set `testPaths` to the spec's own folder (`specs/<feature>/`,
forward-slash with trailing slash) once, after the nothing-to-record guard —
deterministic over (root, feature) and independent of artifact locations.
Remove the now-orphaned `appendUnique` helper.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@protonspy protonspy merged commit 9557ea1 into main Jun 8, 2026
3 checks passed
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.

1 participant