The asyncify single-slot work, executed red-green (full ledger: docs/features/asyncify-arbiter/redgreen.md; decisions record: docs/features/async/07-decisions-and-outcome.md): - tests/apps/standalone/asyncify-races/ + tests/asyncify/ + dedicated playwright config: 8 scenarios reproducing the KiCad asyncify failure family with the kicad-faithful startup topology (pre-park fiber swap → park throw through the live trampoline). Built in 3 variants; the SHIM_DISABLE_TRAMPOLINE_HEAL / SHIM_DISABLE_HANDLESLEEP ablation builds keep the historical hang and index-out-of-bounds crash reproducible forever (mutation-style pins for the existing shims). - scripts/common/shims/handlesleep.js: catch the "unwind" park sentinel in the wakeUp path — when main's last pre-park suspension was a sleep, the main-loop park throw escaped through that sleep's promise reaction as an uncaught rejection (the calculator/gerbview console errors). - scripts/common/inject-dyncall-shims.sh: SHIM_DISABLE_* ablation knobs. - Spec tightening (the acceptance bar): 'uncaught exception: unwind' tolerance DELETED from pcbnew/eeschema specs; load-pcb gained a hard clean-console gate over 5 asyncify corruption signatures. - wxwidgets pointer bump: modal LIFO resolvers, pump resolve-on-error, sync clipboard IsSupported (014f67e6c1). Final state: asyncify suite 7/7, wx e2e 291/292 (1 skip), KiCad e2e 40 passed / 2 skipped with ZERO corruption signatures in any log across all six apps. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
80 lines
2.3 KiB
TypeScript
80 lines
2.3 KiB
TypeScript
import { defineConfig, devices } from '@playwright/test';
|
|
import { execSync } from 'child_process';
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
|
|
// Runs the Asyncify race-condition red-green harness (tests/asyncify/) in both
|
|
// Firefox and system Chrome. Mirrors playwright-coroutine.config.ts (Chrome must
|
|
// be --headed on ARM Mac; Firefox headless OK).
|
|
|
|
const PORT_FILE = path.join(__dirname, '.test-port-asyncify');
|
|
|
|
function findFreePort(): number {
|
|
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 {
|
|
return 9100 + Math.floor(Math.random() * 800);
|
|
}
|
|
}
|
|
|
|
// Same port-pinning scheme as playwright-kicad.config.ts: the main runner picks a
|
|
// fresh port and writes the file before workers spawn; workers always reuse it.
|
|
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 { /* fall through */ }
|
|
}
|
|
const port = findFreePort();
|
|
fs.writeFileSync(PORT_FILE, port.toString());
|
|
return port;
|
|
}
|
|
|
|
const port = resolvePort();
|
|
|
|
export default defineConfig({
|
|
globalSetup: './global-setup.ts',
|
|
testDir: './asyncify',
|
|
testMatch: /asyncify-races.*\.spec\.ts$/,
|
|
fullyParallel: false, // one heavy WASM app at a time
|
|
forbidOnly: !!process.env.CI,
|
|
retries: 0,
|
|
workers: 1,
|
|
reporter: 'html',
|
|
timeout: 120000,
|
|
|
|
use: {
|
|
baseURL: `http://localhost:${port}`,
|
|
trace: 'retain-on-failure',
|
|
screenshot: 'only-on-failure',
|
|
},
|
|
|
|
projects: [
|
|
{
|
|
// Firefox: headless, reliable on ARM Mac.
|
|
name: 'firefox',
|
|
use: { ...devices['Desktop Firefox'], viewport: { width: 1280, height: 720 } },
|
|
},
|
|
{
|
|
// System Chrome (real V8) — run via: npm run test:asyncify:chrome (must be --headed).
|
|
name: 'chromium',
|
|
use: {
|
|
channel: 'chrome',
|
|
viewport: { width: 1280, height: 720 },
|
|
permissions: ['clipboard-read', 'clipboard-write'],
|
|
},
|
|
},
|
|
],
|
|
|
|
webServer: {
|
|
command: `npx serve apps -p ${port} -c ../serve.json`,
|
|
port: port,
|
|
reuseExistingServer: !process.env.CI,
|
|
},
|
|
});
|