From 4b0382791da283162a8397d308f4dcda9fc6ae20 Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Tue, 1 Sep 2026 13:31:40 -0400 Subject: [PATCH] fix(smoke): isolate parallel tsx transforms --- scripts/smoke-discovery.ts | 6 +++--- tests/smoke-discovery.test.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 tests/smoke-discovery.test.ts diff --git a/scripts/smoke-discovery.ts b/scripts/smoke-discovery.ts index 79808dd5..1f79b0ef 100644 --- a/scripts/smoke-discovery.ts +++ b/scripts/smoke-discovery.ts @@ -100,11 +100,11 @@ export function discoverSmokeFiles(root = process.cwd()): string[] { return files.filter((file) => !excluded.has(file)).sort() } -function toCommand(file: string): SmokeCommand { +function toCommand(file: string, disableTsxCache = false): SmokeCommand { return { name: file, command: file.endsWith(".php") ? "php" : file.endsWith(".mjs") ? "node" : "tsx", - args: [file], + args: disableTsxCache && file.endsWith(".ts") ? ["--no-cache", file] : [file], } } @@ -114,7 +114,7 @@ export function discoveredCommands(root = process.cwd()): SmokeCommand[] { /** Files safe to run concurrently. */ export function discoveredParallelCommands(root = process.cwd()): SmokeCommand[] { - return discoverSmokeFiles(root).filter((file) => !serial.has(file)).map(toCommand) + return discoverSmokeFiles(root).filter((file) => !serial.has(file)).map((file) => toCommand(file, true)) } /** Files that must run one at a time, after the parallel phase. */ diff --git a/tests/smoke-discovery.test.ts b/tests/smoke-discovery.test.ts new file mode 100644 index 00000000..7a918375 --- /dev/null +++ b/tests/smoke-discovery.test.ts @@ -0,0 +1,26 @@ +import assert from "node:assert/strict" +import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises" +import { tmpdir } from "node:os" +import { join } from "node:path" + +import { discoveredParallelCommands, discoveredSerialCommands } from "../scripts/smoke-discovery.js" + +const root = await mkdtemp(join(tmpdir(), "wp-codebox-smoke-discovery-")) + +try { + await mkdir(join(root, "tests")) + await mkdir(join(root, "scripts")) + await writeFile(join(root, "tests", "parallel.test.ts"), "") + await writeFile(join(root, "tests", "recipe-step-continuation.integration.test.ts"), "") + await writeFile(join(root, "scripts", "native-smoke.php"), "") + + assert.deepEqual(discoveredParallelCommands(root), [ + { name: "scripts/native-smoke.php", command: "php", args: ["scripts/native-smoke.php"] }, + { name: "tests/parallel.test.ts", command: "tsx", args: ["--no-cache", "tests/parallel.test.ts"] }, + ]) + assert.deepEqual(discoveredSerialCommands(root), [ + { name: "tests/recipe-step-continuation.integration.test.ts", command: "tsx", args: ["tests/recipe-step-continuation.integration.test.ts"] }, + ]) +} finally { + await rm(root, { recursive: true, force: true }) +}