Suite went 64 failed → 291 passed / 0 failed: - Makefile.wasm: compile with -MMD -MP and include .d files — stale objects relinked against a newer wx lib crashed apps at startup with "function signature mismatch" after any header/vtable change - playwright(.coroutine).config.ts: pin the server port for the whole run (resolvePort from playwright-kicad.config.ts); the 60s freshness window made workers restarted after a failure rotate to a dead port (ERR_CONNECTION_REFUSED cascade across ~50 tests) - drop legacy-GL testing: KiCad renders via WebGL GAL (gal-webgl.spec.ts); remove minimal_test's OpenGL tab/GLTestCanvas, opengl.spec.ts, GL z-order describes, -sLEGACY_GL_EMULATION + gl_immediate_shim.js from the test build, and the orphaned GL baselines - coroutine-pthread repro apps join the `all` target (make clean used to delete them while all never rebuilt them); clean no longer eats checked-in JS like worker_dom_stub.js - bump wxwidgets: guard module-eval document access so wx+pthread apps (threadpool tests) survive Web Worker eval Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
96 lines
3.3 KiB
TypeScript
96 lines
3.3 KiB
TypeScript
import { defineConfig, devices } from '@playwright/test';
|
|
import { execSync } from 'child_process';
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
|
|
const PORT_FILE = path.join(__dirname, '.test-port');
|
|
|
|
// Resolve the static-server port for this run.
|
|
//
|
|
// This config file is re-imported by EVERY Playwright process: the main runner
|
|
// (which launches the webServer) and each worker process (which calls
|
|
// page.goto(baseURL)). They must all agree on one port. Playwright also
|
|
// *recreates* a worker mid-run after a test times out or crashes — and that new
|
|
// worker re-imports this config.
|
|
//
|
|
// The previous heuristic ("reuse .test-port if it's <60s old, else pick a new
|
|
// free port") broke exactly there: once a run passed the 60s mark, a recreated
|
|
// worker treated the file as stale, picked a DIFFERENT free port, and every
|
|
// subsequent page.goto hit a dead port (net::ERR_CONNECTION_REFUSED) because the
|
|
// webServer was still listening on the original port. A single failing test
|
|
// thus cascaded into ~all later tests failing.
|
|
//
|
|
// Fix (same as playwright-kicad.config.ts): drop the time window entirely. The
|
|
// main runner always picks a fresh port and writes it; workers always reuse
|
|
// whatever the main runner wrote. The main runner is the only process whose
|
|
// argv carries the `test` command (workers are forked with an empty argv), and
|
|
// it imports this config — and so writes the file — before any worker is
|
|
// spawned.
|
|
function resolvePort(): number {
|
|
const isMainRunner = process.argv.slice(2).includes('test');
|
|
if (!isMainRunner) {
|
|
try {
|
|
const existing = parseInt(fs.readFileSync(PORT_FILE, 'utf-8').trim(), 10);
|
|
if (existing > 0 && existing < 65536) {
|
|
return existing;
|
|
}
|
|
} catch {
|
|
// No readable port file — fall through. Shouldn't happen in a worker,
|
|
// since the main runner writes the file before spawning workers.
|
|
}
|
|
}
|
|
|
|
const port = findFreePort();
|
|
fs.writeFileSync(PORT_FILE, port.toString());
|
|
return port;
|
|
}
|
|
|
|
// Find a free port dynamically using a shell command
|
|
function findFreePort(): number {
|
|
// Use Python to find a free port (works on macOS and Linux)
|
|
try {
|
|
const result = execSync(
|
|
'python3 -c "import socket; s=socket.socket(); s.bind((\'\',0)); print(s.getsockname()[1]); s.close()"',
|
|
{ encoding: 'utf-8' }
|
|
);
|
|
return parseInt(result.trim());
|
|
} catch {
|
|
// Fallback to default port range
|
|
return 9000 + Math.floor(Math.random() * 1000);
|
|
}
|
|
}
|
|
|
|
const port = resolvePort();
|
|
|
|
export default defineConfig({
|
|
globalSetup: './global-setup.ts',
|
|
testDir: './e2e',
|
|
fullyParallel: true,
|
|
forbidOnly: !!process.env.CI,
|
|
// 1 local retry absorbs transient `npx serve` connection refusals under heavy
|
|
// parallel load (many workers fetching large WASM bundles at once).
|
|
retries: process.env.CI ? 2 : 1,
|
|
workers: process.env.CI ? 1 : undefined,
|
|
reporter: 'html',
|
|
timeout: 60000, // WASM can be slow to load
|
|
|
|
use: {
|
|
baseURL: `http://localhost:${port}`,
|
|
trace: 'on-first-retry',
|
|
// Grant clipboard and font permissions for tests
|
|
permissions: ['clipboard-read', 'clipboard-write', 'local-fonts'],
|
|
},
|
|
|
|
projects: [
|
|
{
|
|
name: 'chromium',
|
|
use: { ...devices['Desktop Chrome'] },
|
|
},
|
|
],
|
|
|
|
webServer: {
|
|
command: `npx serve apps -p ${port} -c ../serve.json`,
|
|
port: port,
|
|
reuseExistingServer: !process.env.CI,
|
|
},
|
|
});
|