Skip to content

Commit d12d287

Browse files
committed
test(cli): #12271 pin runs a real command, so it reaches the reroute with or without an oclif manifest
Claude-Session: https://claude.ai/code/session_012YTKj54wfJ886NzwKz1oba Co-authored-by: Claude <noreply@anthropic.com>
1 parent e4b5641 commit d12d287

1 file changed

Lines changed: 25 additions & 9 deletions

File tree

‎packages/cli/test/published-entry-node-env-source-reroute.test.ts‎

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ const CHILD_BUDGET_MS = 120_000;
139139
const CARD_SIGNATURE = "Cannot find module './registry'";
140140

141141
/**
142-
* The reroute itself, visible in oclif's own warning block: it names the module
143-
* it failed to load, and under the reroute that path is under `src/commands`.
142+
* The reroute itself, visible in oclif's own report: it names the module it
143+
* failed to load, and under the reroute that path is under `src/commands`.
144144
*/
145145
const SOURCE_COMMANDS = join('packages', 'cli', 'src', 'commands');
146146

@@ -170,10 +170,26 @@ afterAll(() => {
170170
/**
171171
* Run the published entry from the armed fixture directory.
172172
*
173-
* `--version` is the probe on purpose: it is the cheapest invocation that still
174-
* makes oclif build its command table, which is where the reroute happens.
175-
* Measured — every command tried (`--version`, `doctor --help`, `compile
176-
* --help`) reproduces identically, so the cheapest one is the honest one.
173+
* `explain object` is the probe because it RUNS a command: oclif has to resolve
174+
* that command's module and import it, which is where the reroute happens, and
175+
* `explain.ts` imports the trapped `chalk` at its top. It prints a static
176+
* reference page and exits 0 with nothing to read from the fixture directory.
177+
*
178+
* ⛔ Not `--version`, which this file used until #23181. `--version` loads no
179+
* command; it reached the reroute only because, with no `oclif.manifest.json`
180+
* beside `package.json`, `Config.load()` builds the command table by importing
181+
* every command module. The `integration` project now writes that manifest for
182+
* the run (`helpers/oclif-manifest.global-setup.ts`), and with it present
183+
* `--version` imports nothing: this leg's CONTROL stopped reproducing the card
184+
* and the three legs above it passed over a fixture that armed nothing. A real
185+
* command reaches the reroute with the manifest and without it, measured both
186+
* ways at the slice that made this change.
187+
*
188+
* `OCLIF_COLUMNS` is set wide so oclif renders the load failure on one line.
189+
* With a manifest the failure arrives as the error `handle()` prints, which is
190+
* word-wrapped at 80 columns on a pipe, and a wrap can fall inside the card's
191+
* signature or a path. A split signature fails the CONTROL; worse, it would
192+
* let every `not.toContain` above pass over text it can no longer match.
177193
*
178194
* ⚠️ `TSX_TSCONFIG_PATH` is cleared explicitly. It is what `bin/run-dev.js`
179195
* sets to pin tsx away from the CWD's tsconfig, and a developer running the
@@ -202,12 +218,12 @@ function runPublishedEntry(
202218
const startedAt = Date.now();
203219
const result = spawnSync(
204220
process.execPath,
205-
[...(options.neutralise ? [`--import=${NEUTRALISER}`] : []), PUBLISHED_ENTRY, '--version'],
221+
[...(options.neutralise ? [`--import=${NEUTRALISER}`] : []), PUBLISHED_ENTRY, 'explain', 'object'],
206222
{
207223
cwd: fixtureCwd,
208224
encoding: 'utf8',
209225
timeout: CHILD_BUDGET_MS,
210-
env: childEnv({ TSX_TSCONFIG_PATH: undefined, ...env }),
226+
env: childEnv({ TSX_TSCONFIG_PATH: undefined, OCLIF_COLUMNS: '100000', ...env }),
211227
},
212228
);
213229
const elapsedMs = Date.now() - startedAt;
@@ -257,7 +273,7 @@ describe('#12271 - the published entry does not reroute to src/ on an ambient NO
257273
* ⚠️ It arms only if oclif can REGISTER tsx (`registerTsx` in `ts-path`).
258274
* When that fails, oclif logs `Could not find tsx` under
259275
* `DEBUG=oclif:config:ts-path` and stays on `dist/`. This leg then prints
260-
* the version line and nothing else, and the legs above pass with the
276+
* the reference page and nothing else, and the legs above pass with the
261277
* declaration deleted. tsx 4.23.15's CommonJS ESM API fails that way on any
262278
* Node without tsx's `registerHooks` path (below 22.22.3 on the 22 line).
263279
* That is why the workspace patches it: see `tsx@4.23.15` under

0 commit comments

Comments
 (0)