From 12550fcc283431fcfa4aead8cb58db9a2cb291ed Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Tue, 18 Aug 2026 13:50:33 -0700 Subject: [PATCH] refactor(test): move shell wrapper fixtures where they read as test data (#15363) --- .gitattributes | 4 ++ .../shell-wrapper-snapshots/README.md | 37 +++++++++++++++++++ .../daemon-bash-rcfile.txt | 0 .../daemon-fish-init.txt | 0 .../daemon-zsh-zlogin.txt | 0 .../daemon-zsh-zprofile.txt | 0 .../daemon-zsh-zshenv.txt | 0 .../daemon-zsh-zshrc.txt | 0 .../local-bash-rcfile.txt | 0 .../local-fish-init.txt | 0 .../local-zsh-zlogin.txt | 0 .../local-zsh-zprofile.txt | 0 .../local-zsh-zshenv.txt | 0 .../local-zsh-zshrc.txt | 0 .../relay-bash-rcfile.txt | 0 .../relay-zsh-zlogin.txt | 0 .../relay-zsh-zprofile.txt | 0 .../relay-zsh-zshenv.txt | 0 .../relay-zsh-zshrc.txt | 0 ...ll-wrapper-generated-file-snapshot.test.ts | 5 ++- 20 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 src/main/__tests__/shell-wrapper-snapshots/README.md rename src/main/{ => __tests__}/shell-wrapper-snapshots/daemon-bash-rcfile.txt (100%) rename src/main/{ => __tests__}/shell-wrapper-snapshots/daemon-fish-init.txt (100%) rename src/main/{ => __tests__}/shell-wrapper-snapshots/daemon-zsh-zlogin.txt (100%) rename src/main/{ => __tests__}/shell-wrapper-snapshots/daemon-zsh-zprofile.txt (100%) rename src/main/{ => __tests__}/shell-wrapper-snapshots/daemon-zsh-zshenv.txt (100%) rename src/main/{ => __tests__}/shell-wrapper-snapshots/daemon-zsh-zshrc.txt (100%) rename src/main/{ => __tests__}/shell-wrapper-snapshots/local-bash-rcfile.txt (100%) rename src/main/{ => __tests__}/shell-wrapper-snapshots/local-fish-init.txt (100%) rename src/main/{ => __tests__}/shell-wrapper-snapshots/local-zsh-zlogin.txt (100%) rename src/main/{ => __tests__}/shell-wrapper-snapshots/local-zsh-zprofile.txt (100%) rename src/main/{ => __tests__}/shell-wrapper-snapshots/local-zsh-zshenv.txt (100%) rename src/main/{ => __tests__}/shell-wrapper-snapshots/local-zsh-zshrc.txt (100%) rename src/main/{ => __tests__}/shell-wrapper-snapshots/relay-bash-rcfile.txt (100%) rename src/main/{ => __tests__}/shell-wrapper-snapshots/relay-zsh-zlogin.txt (100%) rename src/main/{ => __tests__}/shell-wrapper-snapshots/relay-zsh-zprofile.txt (100%) rename src/main/{ => __tests__}/shell-wrapper-snapshots/relay-zsh-zshenv.txt (100%) rename src/main/{ => __tests__}/shell-wrapper-snapshots/relay-zsh-zshrc.txt (100%) diff --git a/.gitattributes b/.gitattributes index cbd3a039dc0..c58a3c5aa36 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18,3 +18,7 @@ # source patch under xterm-src/ instead. The sibling patches stay diffable. /config/patches/@xterm__xterm@*.patch -diff /config/patches/xterm-src/*.patch text eol=lf +# 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 diff --git a/src/main/__tests__/shell-wrapper-snapshots/README.md b/src/main/__tests__/shell-wrapper-snapshots/README.md new file mode 100644 index 00000000000..b3c5e66d20d --- /dev/null +++ b/src/main/__tests__/shell-wrapper-snapshots/README.md @@ -0,0 +1,37 @@ +# Shell wrapper snapshots + +Generated test fixtures. **Do not edit by hand.** + +Each `.txt` here is the byte-exact content of one shell startup file Orca writes +into a pane's wrapper `ZDOTDIR`, captured per transport: + +| | | +| :--- | :--- | +| `local-*` | local PTY | +| `daemon-*` | daemon / SSH host | +| `relay-*` | relay overlay | + +Owned by [`../../shell-wrapper-generated-file-snapshot.test.ts`](../../shell-wrapper-generated-file-snapshot.test.ts), +which drives the real wrapper entry points, reads the files back off disk and +compares them here. The temp wrapper root is normalized to `` — +the only path-dependent bytes in the output. + +## Why these exist + +The three zsh generators were once copy-pasted and drifted, so a fix landed in +one transport and silently missed the other two. These pin all three at once, so +drift shows up as a reviewable shell diff instead of hiding in a TypeScript +template literal. + +## Regenerating + +Run the test and review the resulting diff: + +```sh +npx vitest run --config config/vitest.config.ts src/main/shell-wrapper-generated-file-snapshot.test.ts +``` + +⚠️ `toMatchFileSnapshot` **rewrites these files on mismatch when run locally** — +only CI fails. So a passing local run proves nothing on its own: always +`git diff` this directory afterwards, and treat any change as a real behavior +change to what users' shells execute until you have explained it. diff --git a/src/main/shell-wrapper-snapshots/daemon-bash-rcfile.txt b/src/main/__tests__/shell-wrapper-snapshots/daemon-bash-rcfile.txt similarity index 100% rename from src/main/shell-wrapper-snapshots/daemon-bash-rcfile.txt rename to src/main/__tests__/shell-wrapper-snapshots/daemon-bash-rcfile.txt diff --git a/src/main/shell-wrapper-snapshots/daemon-fish-init.txt b/src/main/__tests__/shell-wrapper-snapshots/daemon-fish-init.txt similarity index 100% rename from src/main/shell-wrapper-snapshots/daemon-fish-init.txt rename to src/main/__tests__/shell-wrapper-snapshots/daemon-fish-init.txt diff --git a/src/main/shell-wrapper-snapshots/daemon-zsh-zlogin.txt b/src/main/__tests__/shell-wrapper-snapshots/daemon-zsh-zlogin.txt similarity index 100% rename from src/main/shell-wrapper-snapshots/daemon-zsh-zlogin.txt rename to src/main/__tests__/shell-wrapper-snapshots/daemon-zsh-zlogin.txt diff --git a/src/main/shell-wrapper-snapshots/daemon-zsh-zprofile.txt b/src/main/__tests__/shell-wrapper-snapshots/daemon-zsh-zprofile.txt similarity index 100% rename from src/main/shell-wrapper-snapshots/daemon-zsh-zprofile.txt rename to src/main/__tests__/shell-wrapper-snapshots/daemon-zsh-zprofile.txt diff --git a/src/main/shell-wrapper-snapshots/daemon-zsh-zshenv.txt b/src/main/__tests__/shell-wrapper-snapshots/daemon-zsh-zshenv.txt similarity index 100% rename from src/main/shell-wrapper-snapshots/daemon-zsh-zshenv.txt rename to src/main/__tests__/shell-wrapper-snapshots/daemon-zsh-zshenv.txt diff --git a/src/main/shell-wrapper-snapshots/daemon-zsh-zshrc.txt b/src/main/__tests__/shell-wrapper-snapshots/daemon-zsh-zshrc.txt similarity index 100% rename from src/main/shell-wrapper-snapshots/daemon-zsh-zshrc.txt rename to src/main/__tests__/shell-wrapper-snapshots/daemon-zsh-zshrc.txt diff --git a/src/main/shell-wrapper-snapshots/local-bash-rcfile.txt b/src/main/__tests__/shell-wrapper-snapshots/local-bash-rcfile.txt similarity index 100% rename from src/main/shell-wrapper-snapshots/local-bash-rcfile.txt rename to src/main/__tests__/shell-wrapper-snapshots/local-bash-rcfile.txt diff --git a/src/main/shell-wrapper-snapshots/local-fish-init.txt b/src/main/__tests__/shell-wrapper-snapshots/local-fish-init.txt similarity index 100% rename from src/main/shell-wrapper-snapshots/local-fish-init.txt rename to src/main/__tests__/shell-wrapper-snapshots/local-fish-init.txt diff --git a/src/main/shell-wrapper-snapshots/local-zsh-zlogin.txt b/src/main/__tests__/shell-wrapper-snapshots/local-zsh-zlogin.txt similarity index 100% rename from src/main/shell-wrapper-snapshots/local-zsh-zlogin.txt rename to src/main/__tests__/shell-wrapper-snapshots/local-zsh-zlogin.txt diff --git a/src/main/shell-wrapper-snapshots/local-zsh-zprofile.txt b/src/main/__tests__/shell-wrapper-snapshots/local-zsh-zprofile.txt similarity index 100% rename from src/main/shell-wrapper-snapshots/local-zsh-zprofile.txt rename to src/main/__tests__/shell-wrapper-snapshots/local-zsh-zprofile.txt diff --git a/src/main/shell-wrapper-snapshots/local-zsh-zshenv.txt b/src/main/__tests__/shell-wrapper-snapshots/local-zsh-zshenv.txt similarity index 100% rename from src/main/shell-wrapper-snapshots/local-zsh-zshenv.txt rename to src/main/__tests__/shell-wrapper-snapshots/local-zsh-zshenv.txt diff --git a/src/main/shell-wrapper-snapshots/local-zsh-zshrc.txt b/src/main/__tests__/shell-wrapper-snapshots/local-zsh-zshrc.txt similarity index 100% rename from src/main/shell-wrapper-snapshots/local-zsh-zshrc.txt rename to src/main/__tests__/shell-wrapper-snapshots/local-zsh-zshrc.txt diff --git a/src/main/shell-wrapper-snapshots/relay-bash-rcfile.txt b/src/main/__tests__/shell-wrapper-snapshots/relay-bash-rcfile.txt similarity index 100% rename from src/main/shell-wrapper-snapshots/relay-bash-rcfile.txt rename to src/main/__tests__/shell-wrapper-snapshots/relay-bash-rcfile.txt diff --git a/src/main/shell-wrapper-snapshots/relay-zsh-zlogin.txt b/src/main/__tests__/shell-wrapper-snapshots/relay-zsh-zlogin.txt similarity index 100% rename from src/main/shell-wrapper-snapshots/relay-zsh-zlogin.txt rename to src/main/__tests__/shell-wrapper-snapshots/relay-zsh-zlogin.txt diff --git a/src/main/shell-wrapper-snapshots/relay-zsh-zprofile.txt b/src/main/__tests__/shell-wrapper-snapshots/relay-zsh-zprofile.txt similarity index 100% rename from src/main/shell-wrapper-snapshots/relay-zsh-zprofile.txt rename to src/main/__tests__/shell-wrapper-snapshots/relay-zsh-zprofile.txt diff --git a/src/main/shell-wrapper-snapshots/relay-zsh-zshenv.txt b/src/main/__tests__/shell-wrapper-snapshots/relay-zsh-zshenv.txt similarity index 100% rename from src/main/shell-wrapper-snapshots/relay-zsh-zshenv.txt rename to src/main/__tests__/shell-wrapper-snapshots/relay-zsh-zshenv.txt diff --git a/src/main/shell-wrapper-snapshots/relay-zsh-zshrc.txt b/src/main/__tests__/shell-wrapper-snapshots/relay-zsh-zshrc.txt similarity index 100% rename from src/main/shell-wrapper-snapshots/relay-zsh-zshrc.txt rename to src/main/__tests__/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 a5c0548f43a..bcf1d7e7483 100644 --- a/src/main/shell-wrapper-generated-file-snapshot.test.ts +++ b/src/main/shell-wrapper-generated-file-snapshot.test.ts @@ -4,6 +4,9 @@ * * 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 + * before accepting a rewrite; a local run updates them silently. */ import { mkdtempSync, readFileSync, rmSync } from 'node:fs' import { tmpdir } from 'node:os' @@ -33,7 +36,7 @@ const WRAPPER_FILES = [ ['bash-rcfile', join('bash', 'rcfile')] ] as const -const SNAPSHOT_DIR = join(__dirname, 'shell-wrapper-snapshots') +const SNAPSHOT_DIR = join(__dirname, '__tests__', '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.