Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 234091a7dff733bd2570ace74dd695ac56d88f06
parent 4832c7072e653cf0e260f57f3ce2ebd4854f73f9
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Sat, 10 Oct 2026 16:13:44 -0400

e2e: a focused run (spec files, a grep) keeps the serial project top-level

Playwright applies spec and grep filters to top-level projects only and runs a
`teardown` project whole, so `E2E_WORKERS=2 pnpm e2e one.spec.ts` ran every
@serial file after it. The runner decides once from its command line
(isFocusedRun) and pins it for the workers (E2E_SERIAL_LAST): a whole run keeps
the serial project last, a focused one keeps only its one-worker limit.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Meditor/e2e/servers.ts | 42++++++++++++++++++++++++++++++++++++++++++
Meditor/e2e/servers.unit.ts | 16+++++++++++++++-
Meditor/playwright.config.ts | 21+++++++++++++++++----
3 files changed, 74 insertions(+), 5 deletions(-)

diff --git a/editor/e2e/servers.ts b/editor/e2e/servers.ts @@ -100,6 +100,48 @@ export function resolveWorkers( return Math.min(MAX_WORKERS, n); } +// ------------------------------------------------------- a focused run + +// Options of `playwright test` that take a value (1.59, `playwright test --help`). +const VALUE_OPTIONS = new Set([ + "--browser", "-c", "--config", "--global-timeout", "-j", "--workers", "--max-failures", "--output", + "--repeat-each", "--reporter", "--retries", "--run-agents", "--timeout", "--trace", "--tsconfig", + "--ui-host", "--ui-port", "--update-source-method", +]); +// …that narrow WHICH tests run (with or without a value). +const FILTER_OPTIONS = new Set([ + "-g", "--grep", "--grep-invert", "--project", "--last-failed", "--only-changed", "--shard", + "--test-list", "--test-list-invert", +]); +// …whose value is optional, given only as one of these words. +const OPTIONAL_VALUES: Record<string, ReadonlySet<string>> = { + "--debug": new Set(["inspector", "cli"]), + "-u": new Set(["all", "changed", "missing", "none"]), + "--update-snapshots": new Set(["all", "changed", "missing", "none"]), +}; + +/** + * Whether this `playwright test` command line narrows the run — a spec file or + * a filter. Playwright applies those to TOP-LEVEL projects only: a `teardown` + * project runs whole, so a focused run must not make the serial project one + * (`pnpm e2e pacing.spec.ts` would run every @serial file). Unsure means + * focused, which only gives up the ordering. + */ +export function isFocusedRun(argv: readonly string[] = process.argv): boolean { + const at = argv.indexOf("test"); + if (at < 0) return true; + for (let i = at + 1; i < argv.length; i++) { + const arg = argv[i]; + const name = arg.startsWith("-") ? arg.split("=")[0] : null; + if (name == null) return true; // a positional: a spec filter + if (FILTER_OPTIONS.has(name)) return true; + if (arg.includes("=")) continue; + if (VALUE_OPTIONS.has(name)) i++; + else if (OPTIONAL_VALUES[name]?.has(argv[i + 1] ?? "")) i++; + } + return false; +} + // -------------------------------------------------------------------- ports export type SlotPorts = { editor: number; export: number; ollama: number }; diff --git a/editor/e2e/servers.unit.ts b/editor/e2e/servers.unit.ts @@ -6,7 +6,7 @@ import { existsSync } from "node:fs"; import { join } from "node:path"; import test from "node:test"; import { SERIAL_SPECS, SERIAL_SPEC_PATTERN } from "./serial"; -import { resolveWorkers, slotPorts, slotServers } from "./servers"; +import { isFocusedRun, resolveWorkers, slotPorts, slotServers } from "./servers"; import { EDITOR_ROOT, slotRoot, testPaths } from "./testPaths"; test("resolveWorkers: 1 by default, a number capped at 8, auto from memory capped at 3", () => { @@ -97,3 +97,17 @@ test("the @serial list names spec files that exist, and matches whole names only assert.ok(!SERIAL_SPEC_PATTERN.test("/x/editor/e2e/my-pacing.spec.ts")); assert.ok(!SERIAL_SPEC_PATTERN.test("/x/editor/e2e/build.spec.tsx")); }); + +test("isFocusedRun: a spec file or a filter narrows the run; options with values do not", () => { + const pw = (...args: string[]) => ["node", "/x/playwright/cli.js", "test", ...args]; + assert.equal(isFocusedRun(pw()), false); + assert.equal(isFocusedRun(pw("--workers", "2", "--reporter", "list", "--retries=1")), false); + assert.equal(isFocusedRun(pw("-u", "all", "--debug", "--headed")), false); + assert.equal(isFocusedRun(pw("pacing.spec.ts")), true); + assert.equal(isFocusedRun(pw("--workers", "2", "pacing.spec.ts", "whisper.spec.ts")), true); + assert.equal(isFocusedRun(pw("-g", "lane")), true); + assert.equal(isFocusedRun(pw("--grep=lane")), true); + assert.equal(isFocusedRun(pw("--last-failed")), true); + assert.equal(isFocusedRun(pw("--project", "serial")), true); + assert.equal(isFocusedRun(["node", "something-else"]), true); // unsure: focused +}); diff --git a/editor/playwright.config.ts b/editor/playwright.config.ts @@ -2,7 +2,7 @@ import { spawnSync } from "node:child_process"; import path from "node:path"; import { defineConfig, devices } from "@playwright/test"; import { SERIAL_SPEC_PATTERN } from "./e2e/serial"; -import { resolveE2EMode, resolveWorkers, slotPorts, slotServers } from "./e2e/servers"; +import { isFocusedRun, resolveE2EMode, resolveWorkers, slotPorts, slotServers } from "./e2e/servers"; import { currentSlot } from "./e2e/testPaths"; // THE TEST-ONLY ENVIRONMENT, declared here (one-core Phase 4 slice 3). Every @@ -159,13 +159,26 @@ const webServer = slot0.map((s) => ({ // @serial: spec files that time wall-clock behaviour under contention, or // write into the checkout's own build outputs (export/out, homepage/out — -// shared by every slot), run after the parallel project, on one worker -// (e2e/serial.ts). With one worker there is one project, as before. +// shared by every slot), run on one worker (e2e/serial.ts) — in a whole run, +// AFTER the parallel project (its `teardown`, which runs even when a parallel +// test failed). A focused run (spec files, a grep) keeps the one-worker limit +// but not the order: Playwright runs a teardown project whole, whatever the +// filter. Decided once, by the runner, and pinned for the workers (their +// argv is not the command line). With one worker there is one project. +if (SLOT === 0 && process.env.TEST_PARALLEL_INDEX == null) { + process.env.E2E_SERIAL_LAST = isFocusedRun() ? "0" : "1"; +} +const SERIAL_LAST = process.env.E2E_SERIAL_LAST === "1"; const browser = { ...devices["Desktop Chrome"] }; const projects = WORKERS > 1 ? [ - { name: "chromium", use: browser, testIgnore: SERIAL_SPEC_PATTERN, teardown: "serial" }, + { + name: "chromium", + use: browser, + testIgnore: SERIAL_SPEC_PATTERN, + ...(SERIAL_LAST ? { teardown: "serial" } : {}), + }, { name: "serial", use: browser, testMatch: SERIAL_SPEC_PATTERN, workers: 1 }, ] : [{ name: "chromium", use: browser }];