Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions scripts/smoke-discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
}
}

Expand All @@ -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. */
Expand Down
26 changes: 26 additions & 0 deletions tests/smoke-discovery.test.ts
Original file line number Diff line number Diff line change
@@ -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 })
}
Loading