From 487e43d61965f00c9874ba220e562e968730944a Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Tue, 18 Aug 2026 14:09:12 -0700 Subject: [PATCH] refactor(test): use __fixtures__ for wrapper snapshots and teach the LoC bot (#15365) --- .gitattributes | 2 +- .github/scripts/pr-test-loc-table.mjs | 5 ++++- config/scripts/pr-test-loc-summary.test.mjs | 11 +++++++++++ .../shell-wrapper-snapshots/README.md | 0 .../shell-wrapper-snapshots/daemon-bash-rcfile.txt | 0 .../shell-wrapper-snapshots/daemon-fish-init.txt | 0 .../shell-wrapper-snapshots/daemon-zsh-zlogin.txt | 0 .../shell-wrapper-snapshots/daemon-zsh-zprofile.txt | 0 .../shell-wrapper-snapshots/daemon-zsh-zshenv.txt | 0 .../shell-wrapper-snapshots/daemon-zsh-zshrc.txt | 0 .../shell-wrapper-snapshots/local-bash-rcfile.txt | 0 .../shell-wrapper-snapshots/local-fish-init.txt | 0 .../shell-wrapper-snapshots/local-zsh-zlogin.txt | 0 .../shell-wrapper-snapshots/local-zsh-zprofile.txt | 0 .../shell-wrapper-snapshots/local-zsh-zshenv.txt | 0 .../shell-wrapper-snapshots/local-zsh-zshrc.txt | 0 .../shell-wrapper-snapshots/relay-bash-rcfile.txt | 0 .../shell-wrapper-snapshots/relay-zsh-zlogin.txt | 0 .../shell-wrapper-snapshots/relay-zsh-zprofile.txt | 0 .../shell-wrapper-snapshots/relay-zsh-zshenv.txt | 0 .../shell-wrapper-snapshots/relay-zsh-zshrc.txt | 0 .../shell-wrapper-generated-file-snapshot.test.ts | 4 ++-- 22 files changed, 18 insertions(+), 4 deletions(-) rename src/main/{__tests__ => __fixtures__}/shell-wrapper-snapshots/README.md (100%) rename src/main/{__tests__ => __fixtures__}/shell-wrapper-snapshots/daemon-bash-rcfile.txt (100%) rename src/main/{__tests__ => __fixtures__}/shell-wrapper-snapshots/daemon-fish-init.txt (100%) rename src/main/{__tests__ => __fixtures__}/shell-wrapper-snapshots/daemon-zsh-zlogin.txt (100%) rename src/main/{__tests__ => __fixtures__}/shell-wrapper-snapshots/daemon-zsh-zprofile.txt (100%) rename src/main/{__tests__ => __fixtures__}/shell-wrapper-snapshots/daemon-zsh-zshenv.txt (100%) rename src/main/{__tests__ => __fixtures__}/shell-wrapper-snapshots/daemon-zsh-zshrc.txt (100%) rename src/main/{__tests__ => __fixtures__}/shell-wrapper-snapshots/local-bash-rcfile.txt (100%) rename src/main/{__tests__ => __fixtures__}/shell-wrapper-snapshots/local-fish-init.txt (100%) rename src/main/{__tests__ => __fixtures__}/shell-wrapper-snapshots/local-zsh-zlogin.txt (100%) rename src/main/{__tests__ => __fixtures__}/shell-wrapper-snapshots/local-zsh-zprofile.txt (100%) rename src/main/{__tests__ => __fixtures__}/shell-wrapper-snapshots/local-zsh-zshenv.txt (100%) rename src/main/{__tests__ => __fixtures__}/shell-wrapper-snapshots/local-zsh-zshrc.txt (100%) rename src/main/{__tests__ => __fixtures__}/shell-wrapper-snapshots/relay-bash-rcfile.txt (100%) rename src/main/{__tests__ => __fixtures__}/shell-wrapper-snapshots/relay-zsh-zlogin.txt (100%) rename src/main/{__tests__ => __fixtures__}/shell-wrapper-snapshots/relay-zsh-zprofile.txt (100%) rename src/main/{__tests__ => __fixtures__}/shell-wrapper-snapshots/relay-zsh-zshenv.txt (100%) rename src/main/{__tests__ => __fixtures__}/shell-wrapper-snapshots/relay-zsh-zshrc.txt (100%) diff --git a/.gitattributes b/.gitattributes index c58a3c5aa36..f4676d210bb 100644 --- a/.gitattributes +++ b/.gitattributes @@ -21,4 +21,4 @@ # Generated wrapper fixtures: collapse them in the PR diff so they stop drowning # the reviewable change, and pin LF because they are compared byte-for-byte. # Not -diff: the shell diff is the review surface when a wrapper does change. -/src/main/__tests__/shell-wrapper-snapshots/*.txt linguist-generated=true text eol=lf +/src/main/__fixtures__/shell-wrapper-snapshots/*.txt linguist-generated=true text eol=lf diff --git a/.github/scripts/pr-test-loc-table.mjs b/.github/scripts/pr-test-loc-table.mjs index 839098475ab..c5d233c4497 100644 --- a/.github/scripts/pr-test-loc-table.mjs +++ b/.github/scripts/pr-test-loc-table.mjs @@ -3,7 +3,10 @@ export const LOC_BLOCK_END = '' export const LOC_HANDS_OFF_COMMENT = '' -const TEST_DIR_SEGMENT = /(?:^|\/)(?:__tests__|e2e|tests)(?:\/|$)/i +// Why the __-wrapped names: they are unambiguous test-data markers, so a dir +// cannot be one by accident. Bare `fixtures/` is deliberately absent — it reads +// as a plausible prod module name, and this classifier bills every PR. +const TEST_DIR_SEGMENT = /(?:^|\/)(?:__tests__|__fixtures__|__snapshots__|e2e|tests)(?:\/|$)/i const TEST_FILENAME = /\.(?:test|spec|e2e)\.[^/]+$/i export function isTestPath(path) { diff --git a/config/scripts/pr-test-loc-summary.test.mjs b/config/scripts/pr-test-loc-summary.test.mjs index b13ab1b4763..044b645a29c 100644 --- a/config/scripts/pr-test-loc-summary.test.mjs +++ b/config/scripts/pr-test-loc-summary.test.mjs @@ -50,6 +50,17 @@ describe('PR test LoC summary', () => { expect(isTestPath('src/main/foo.ts')).toBe(false) }) + it('classifies __fixtures__ and __snapshots__ data of any extension', () => { + expect(isTestPath('src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zshrc.txt')).toBe( + true + ) + expect(isTestPath('src/shared/__fixtures__/trace.json')).toBe(true) + expect(isTestPath('src/main/runtime/orchestration/__snapshots__/run.test.ts.snap')).toBe(true) + // Why: only the __-wrapped names count; a bare `fixtures` dir stays prod. + expect(isTestPath('src/main/daemon/fixtures/ratatui-tui.py')).toBe(false) + expect(isTestPath('src/main/my__fixtures__helper.ts')).toBe(false) + }) + it('sums GitHub pull-file additions and deletions', () => { const totals = sumChangedFiles([ { filename: 'src/app.ts', additions: 4, deletions: 1 }, diff --git a/src/main/__tests__/shell-wrapper-snapshots/README.md b/src/main/__fixtures__/shell-wrapper-snapshots/README.md similarity index 100% rename from src/main/__tests__/shell-wrapper-snapshots/README.md rename to src/main/__fixtures__/shell-wrapper-snapshots/README.md diff --git a/src/main/__tests__/shell-wrapper-snapshots/daemon-bash-rcfile.txt b/src/main/__fixtures__/shell-wrapper-snapshots/daemon-bash-rcfile.txt similarity index 100% rename from src/main/__tests__/shell-wrapper-snapshots/daemon-bash-rcfile.txt rename to src/main/__fixtures__/shell-wrapper-snapshots/daemon-bash-rcfile.txt diff --git a/src/main/__tests__/shell-wrapper-snapshots/daemon-fish-init.txt b/src/main/__fixtures__/shell-wrapper-snapshots/daemon-fish-init.txt similarity index 100% rename from src/main/__tests__/shell-wrapper-snapshots/daemon-fish-init.txt rename to src/main/__fixtures__/shell-wrapper-snapshots/daemon-fish-init.txt diff --git a/src/main/__tests__/shell-wrapper-snapshots/daemon-zsh-zlogin.txt b/src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zlogin.txt similarity index 100% rename from src/main/__tests__/shell-wrapper-snapshots/daemon-zsh-zlogin.txt rename to src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zlogin.txt diff --git a/src/main/__tests__/shell-wrapper-snapshots/daemon-zsh-zprofile.txt b/src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zprofile.txt similarity index 100% rename from src/main/__tests__/shell-wrapper-snapshots/daemon-zsh-zprofile.txt rename to src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zprofile.txt diff --git a/src/main/__tests__/shell-wrapper-snapshots/daemon-zsh-zshenv.txt b/src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zshenv.txt similarity index 100% rename from src/main/__tests__/shell-wrapper-snapshots/daemon-zsh-zshenv.txt rename to src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zshenv.txt diff --git a/src/main/__tests__/shell-wrapper-snapshots/daemon-zsh-zshrc.txt b/src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zshrc.txt similarity index 100% rename from src/main/__tests__/shell-wrapper-snapshots/daemon-zsh-zshrc.txt rename to src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zshrc.txt diff --git a/src/main/__tests__/shell-wrapper-snapshots/local-bash-rcfile.txt b/src/main/__fixtures__/shell-wrapper-snapshots/local-bash-rcfile.txt similarity index 100% rename from src/main/__tests__/shell-wrapper-snapshots/local-bash-rcfile.txt rename to src/main/__fixtures__/shell-wrapper-snapshots/local-bash-rcfile.txt diff --git a/src/main/__tests__/shell-wrapper-snapshots/local-fish-init.txt b/src/main/__fixtures__/shell-wrapper-snapshots/local-fish-init.txt similarity index 100% rename from src/main/__tests__/shell-wrapper-snapshots/local-fish-init.txt rename to src/main/__fixtures__/shell-wrapper-snapshots/local-fish-init.txt diff --git a/src/main/__tests__/shell-wrapper-snapshots/local-zsh-zlogin.txt b/src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zlogin.txt similarity index 100% rename from src/main/__tests__/shell-wrapper-snapshots/local-zsh-zlogin.txt rename to src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zlogin.txt diff --git a/src/main/__tests__/shell-wrapper-snapshots/local-zsh-zprofile.txt b/src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zprofile.txt similarity index 100% rename from src/main/__tests__/shell-wrapper-snapshots/local-zsh-zprofile.txt rename to src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zprofile.txt diff --git a/src/main/__tests__/shell-wrapper-snapshots/local-zsh-zshenv.txt b/src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zshenv.txt similarity index 100% rename from src/main/__tests__/shell-wrapper-snapshots/local-zsh-zshenv.txt rename to src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zshenv.txt diff --git a/src/main/__tests__/shell-wrapper-snapshots/local-zsh-zshrc.txt b/src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zshrc.txt similarity index 100% rename from src/main/__tests__/shell-wrapper-snapshots/local-zsh-zshrc.txt rename to src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zshrc.txt diff --git a/src/main/__tests__/shell-wrapper-snapshots/relay-bash-rcfile.txt b/src/main/__fixtures__/shell-wrapper-snapshots/relay-bash-rcfile.txt similarity index 100% rename from src/main/__tests__/shell-wrapper-snapshots/relay-bash-rcfile.txt rename to src/main/__fixtures__/shell-wrapper-snapshots/relay-bash-rcfile.txt diff --git a/src/main/__tests__/shell-wrapper-snapshots/relay-zsh-zlogin.txt b/src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zlogin.txt similarity index 100% rename from src/main/__tests__/shell-wrapper-snapshots/relay-zsh-zlogin.txt rename to src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zlogin.txt diff --git a/src/main/__tests__/shell-wrapper-snapshots/relay-zsh-zprofile.txt b/src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zprofile.txt similarity index 100% rename from src/main/__tests__/shell-wrapper-snapshots/relay-zsh-zprofile.txt rename to src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zprofile.txt diff --git a/src/main/__tests__/shell-wrapper-snapshots/relay-zsh-zshenv.txt b/src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zshenv.txt similarity index 100% rename from src/main/__tests__/shell-wrapper-snapshots/relay-zsh-zshenv.txt rename to src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zshenv.txt diff --git a/src/main/__tests__/shell-wrapper-snapshots/relay-zsh-zshrc.txt b/src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zshrc.txt similarity index 100% rename from src/main/__tests__/shell-wrapper-snapshots/relay-zsh-zshrc.txt rename to src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zshrc.txt diff --git a/src/main/shell-wrapper-generated-file-snapshot.test.ts b/src/main/shell-wrapper-generated-file-snapshot.test.ts index bcf1d7e7483..bf34df55e86 100644 --- a/src/main/shell-wrapper-generated-file-snapshot.test.ts +++ b/src/main/shell-wrapper-generated-file-snapshot.test.ts @@ -5,7 +5,7 @@ * Why: the zsh generators were unified behind one builder; these fixtures were * captured from the pre-unification code so any drift shows up as a diff. * - * Fixtures live in ./__tests__/shell-wrapper-snapshots/ — see the README there + * Fixtures live in ./__fixtures__/shell-wrapper-snapshots/ — see the README there * before accepting a rewrite; a local run updates them silently. */ import { mkdtempSync, readFileSync, rmSync } from 'node:fs' @@ -36,7 +36,7 @@ const WRAPPER_FILES = [ ['bash-rcfile', join('bash', 'rcfile')] ] as const -const SNAPSHOT_DIR = join(__dirname, '__tests__', 'shell-wrapper-snapshots') +const SNAPSHOT_DIR = join(__dirname, '__fixtures__', 'shell-wrapper-snapshots') // Why: the wrapper root is a temp dir per run, and the baked ZDOTDIR literal is // the only path-dependent byte in the output; pin it to a stable placeholder.