Skip to content

refactor(test): use __fixtures__ for wrapper snapshots and teach the LoC bot - #15365

Merged
nwparker merged 1 commit into
mainfrom
nwparker/fixtures-dir-and-loc-classifier
Aug 18, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/fixtures-dir-and-loc-classifier

Conversation

@nwparker

@nwparker nwparker commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​13 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​11
Prod 20 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3

ELI5

Last PR put the generated shell-wrapper fixtures in a folder called __tests__. That was picked to satisfy the bot that counts test-vs-prod lines, not because it was the right name — this repo already keeps non-TS test data in __fixtures__. So: rename the folder to the one we actually use, and fix the bot instead of bending the layout around it.

What Changed

  • src/main/__tests__/shell-wrapper-snapshots/ → src/main/__fixtures__/shell-wrapper-snapshots/ (18 pure renames, src/main/__tests__/ removed)
  • .github/scripts/pr-test-loc-table.mjs: isTestPath now also counts __fixtures__ and __snapshots__ path segments
  • Test + .gitattributes references updated; new classifier cases in config/scripts/pr-test-loc-summary.test.mjs
-const TEST_DIR_SEGMENT = /(?:^|\/)(?:__tests__|e2e|tests)(?:\/|$)/i
+const TEST_DIR_SEGMENT = /(?:^|\/)(?:__tests__|__fixtures__|__snapshots__|e2e|tests)(?:\/|$)/i

Why

__fixtures__ is this repo's existing convention for non-TS test data — src/shared/__fixtures__, src/main/startup/__fixtures__, src/renderer/src/components/terminal-pane/__fixtures__. src/main/providers/__tests__ is the lone __tests__ dir; everything else co-locates *.test.ts. #15363 used __tests__ purely because it was the only name isTestPath matched, which is the layout following the tool rather than the other way round.

Fixing the classifier also corrects five directories that are misbilled as prod today, independent of this move:

Dir Before After
src/shared/__fixtures__ PROD TEST
src/main/startup/__fixtures__ PROD TEST
src/renderer/src/components/terminal-pane/__fixtures__ PROD TEST
src/main/runtime/orchestration/__snapshots__ PROD TEST
src/renderer/src/components/settings/__snapshots__ PROD TEST

Why only the __-wrapped names

Both added names are __-wrapped, so a directory cannot carry one by accident. Bare fixtures/ is deliberately not added: it reads as a plausible production module name, and this classifier bills every PR in the repo, so a false positive there is worse than a missed test dir. The two bare fixtures/ dirs outside tests/ (config/scripts/fixtures/, src/main/daemon/fixtures/) stay prod, and there is an explicit test pinning that.

This PR's own LoC table will be wrong — expected

pr-test-loc.yml fetches the classifier from the default branch, never pull/<n>/head, because the job holds a write-scoped GITHUB_TOKEN and may only execute reviewed code. So the table on this PR is still computed with the old regex; the fix applies from the next PR onward. Low stakes here — the fixtures move as renames, which carry 0 added/deleted lines either way.

Testing

Platform: macOS 26.3.1 (arm64).

  • Byte-identity, proven not asserted: sha256 of all 18 moved files compared against origin/main — all identical. git show --stat -M shows every fixture as | 0.
  • shell-wrapper-generated-file-snapshot.test.ts — 7 passed, and git diff on the fixture dir is empty afterwards. That second check is the one that counts: toMatchFileSnapshot rewrites fixtures on mismatch outside CI, so a green run alone proves nothing.
  • config/scripts/pr-test-loc-summary.test.mjs — 14 passed, including the new case asserting __fixtures__/__snapshots__ are test and bare fixtures/ plus my__fixtures__helper.ts are not.
  • Classifier spot-checked directly against the real paths in the table above.
  • npx vitest run over src/main/providers/, src/main/daemon/, src/relay/, config/scripts/ — 4540 passed. The 3 failures in pty-subprocess-env-inheritance.test.ts are pre-existing on main (12550fc): verified by stashing this branch's changes and re-running against a clean tree, where they fail identically.
  • npx tsc --noEmit -p config/tsconfig.node.json, npx oxlint, npx oxfmt --check — all clean. check-max-lines-ratchet — OK, no new bypasses.
  • No stale references: git grep '__tests__/shell-wrapper' returns nothing. The README's ../../ link still resolves (depth unchanged).

Cross-platform: no runtime code touched. The text eol=lf pin on the fixtures carries over to the new path, so byte-for-byte comparison stays safe against a CRLF checkout.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Visual Proof

N/A — no UI surface. Directory rename, a regex, and its tests.

Linked Issue

N/A — review follow-up to #15363 / #15245.

Notes

Security: pr-test-loc.yml is unchanged — the trusted-ref fetch that keeps the write-scoped token away from PR-authored code stays exactly as it is. This PR only edits the script that action pulls from the default branch. Performance and backwards compatibility: none, test-only.

Still not in this PR: the three bash rcfile generators remain three near-identical copies (345 / 339 / 319 fixture lines each) — #15245 unified zsh only.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…LoC bot

#15363 parked the generated wrapper fixtures under __tests__ because that was
the only name the PR LoC classifier recognized. __fixtures__ is the convention
this repo already uses for non-TS test data (src/shared, src/main/startup,
terminal-pane), so fix the classifier instead of bending the layout around it.

isTestPath now also counts __fixtures__ and __snapshots__ segments. Both are
__-wrapped, so a directory cannot carry the name by accident. Bare fixtures/ is
deliberately left out: it reads as a plausible prod module name, and this
classifier bills every PR in the repo.

That also un-bills five dirs that were already misclassified as prod today:
3 __fixtures__ and 2 __snapshots__.

All 18 files are pure renames, verified byte-identical to main by sha256.
@coderabbitai

coderabbitai Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7b7cdb05-306b-4802-940b-77f9cd90c090

📥 Commits

Reviewing files that changed from the base of the PR and between 12550fc and b6d29c2.

📒 Files selected for processing (22)
  • .gitattributes
  • .github/scripts/pr-test-loc-table.mjs
  • config/scripts/pr-test-loc-summary.test.mjs
  • src/main/__fixtures__/shell-wrapper-snapshots/README.md
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-bash-rcfile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-fish-init.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zlogin.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zprofile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zshenv.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zshrc.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-bash-rcfile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-fish-init.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zlogin.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zprofile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zshenv.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zshrc.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/relay-bash-rcfile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zlogin.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zprofile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zshenv.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zshrc.txt
  • src/main/shell-wrapper-generated-file-snapshot.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The change moves shell-wrapper snapshots from __tests__ to __fixtures__ and updates generated-file metadata and snapshot test paths. Test-path classification now recognizes __fixtures__ and __snapshots__, with coverage for positive and negative cases. Documentation describes snapshot ownership and regeneration. Bash, Fish, and zsh shell wrapper fixtures are added for daemon, local, and relay transports.

Merge Risk: ⚪ Minimal · up to b6d29

This PR only relocates byte-identical test fixtures and updates test-path classification with focused tests; it does not change production behavior or deployment configuration. No actionable merge-blocking risk remains after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is detailed and covers the changes and testing, but it marks the required linked issue as N/A. Provide a valid linked issue reference instead of N/A, and complete the remaining template sections if required by repository policy.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the directory rename and classifier update, which are the main changes in the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7b7cdb05-306b-4802-940b-77f9cd90c090

📥 Commits

Reviewing files that changed from the base of the PR and between 12550fc and b6d29c2.

📒 Files selected for processing (22)
  • .gitattributes
  • .github/scripts/pr-test-loc-table.mjs
  • config/scripts/pr-test-loc-summary.test.mjs
  • src/main/__fixtures__/shell-wrapper-snapshots/README.md
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-bash-rcfile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-fish-init.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zlogin.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zprofile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zshenv.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zshrc.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-bash-rcfile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-fish-init.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zlogin.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zprofile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zshenv.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zshrc.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/relay-bash-rcfile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zlogin.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zprofile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zshenv.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zshrc.txt
  • src/main/shell-wrapper-generated-file-snapshot.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zshenv.txt (1)

53-60: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Set ZDOTDIR to ORCA_ORIG_ZDOTDIR before sourcing the relay user .zshenv.

ZDOTDIR still points to the Orca wrapper when "$ORCA_ORIG_ZDOTDIR/.zshenv" runs. User startup files that resolve paths through $ZDOTDIR can load the wrong files. Apply this change only to relay-zsh-zshenv.txt; the discovery wrappers intentionally unset ZDOTDIR before sourcing.

src/main/__fixtures__/shell-wrapper-snapshots/README.md (1)

34-36: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Correct the local snapshot-update warning.

The command does not pass --update. Vitest’s local default is update: 'new', which writes missing snapshots but fails on mismatches. Use -u/--update to rewrite changed snapshots.

src/main/__fixtures__/shell-wrapper-snapshots/relay-bash-rcfile.txt (1)

53-55: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Define omp only when the extension file exists.

A stale ORCA_OMP_STATUS_EXTENSION replaces the user's omp function, then __orca_omp bypasses it with command omp. Use [[ -f "${ORCA_OMP_STATUS_EXTENSION:-}" ]] for this guard.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7b7cdb05-306b-4802-940b-77f9cd90c090

📥 Commits

Reviewing files that changed from the base of the PR and between 12550fc and b6d29c2.

📒 Files selected for processing (22)
  • .gitattributes
  • .github/scripts/pr-test-loc-table.mjs
  • config/scripts/pr-test-loc-summary.test.mjs
  • src/main/__fixtures__/shell-wrapper-snapshots/README.md
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-bash-rcfile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-fish-init.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zlogin.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zprofile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zshenv.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zshrc.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-bash-rcfile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-fish-init.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zlogin.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zprofile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zshenv.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zshrc.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/relay-bash-rcfile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zlogin.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zprofile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zshenv.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zshrc.txt
  • src/main/shell-wrapper-generated-file-snapshot.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.

@nwparker
nwparker merged commit 487e43d into main Aug 18, 2026
47 checks passed
@nwparker
nwparker deleted the nwparker/fixtures-dir-and-loc-classifier branch August 18, 2026 21:09
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 21, 2026
dallascrilley pushed a commit to dallascrilley/orca that referenced this pull request Aug 27, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 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.

1 participant