pcbjam/tests/jspi/jspi-coroutine.spec.ts
Viktor Vaczi db819850ee jspi: fix the dead-tools ownership bug, emscripten-6 fallout, and green the full suite on Playwright 1.62
Live-app fix (Place Footprints / routing dead in Chrome): submodule
bumps carry the coroutine ownership fix (kicad 012d95ecb4) and the
handler-exception survival fix (wxwidgets 1b5f0e31f4).

Emscripten-6 fallout:
- occ/ngspice worker wrappers: mainScriptUrlOrBlob was removed
  upstream; pthread children re-run the wrapper blob, so an em-pthread
  realm now importScripts the glue and gets out of the way (before:
  recursive service boots, pool never fills, silent 180s boot hangs —
  every occ spec and ngspice bg_run).
- Makefile.wasm: -sASYNCIFY frankenlinks on the no-wx coroutine repro
  targets ported to -sJSPI (the JSPI-only libcontext crashed at first
  yield under them); mainloop/gl repro pages drive their tick through a
  promising export (emscripten_set_main_loop callbacks cannot suspend);
  retired inject-dyncall-shims lines removed (targets were unbuildable
  since Phase 8); $stringToNewUTF8 force-included (the EM_ASM value
  bridge aborted the runtime on the first decoded exception).
- fiber-park levers: neither embind shape can drive suspending levers
  (plain throws on strict-JSPI Firefox; emscripten::async() re-executes
  its invoker on settle) — kept sync for manual Chromium probing, spec
  coverage moved to the jspi-coroutine harness (18 cases).

Suite work:
- Playwright 1.61.1 -> 1.62.1 (Firefox 153: JSPI on by default).
- fiber-resume-park.spec retired -> coroutine-lifecycle.spec: census
  gate over boot / board load / chooser open / cancel (deterministically
  red on the pre-fix build).
- Blind asyncify-era pins re-keyed: quasimodal-strand + wait-beacons
  beacon regexes, footprint-chooser-close liveness -> wx parking-timer
  heartbeat (scheduler counters idle flat on Firefox).
- occ/ngspice test providers: 60s boot timeout + worker error
  surfacing (a worker death used to be a silent 180s timeout).
- Harness pages: stale 9.99 config dir -> 10.0 (library_manager wxCHECK
  noise, chooser had no libraries).
- gal-webgl harness: missing artifacts rebuilt (boost/glm extracted to
  the host sysroot), PgmOrNull stub added for the rebased GAL.
- jspi-scheduler: clean-shutdown console line restored (app-quit
  contract), quarantine never yanks SP from a live window.

Gates: test:e2e 699 passed / 0 failed (wx-chromium, kicad-firefox,
kicad-chromium, jspi-firefox, coroutine-firefox); web ff/cr/mobile 71
passed; lint:ci-coverage 166, lint:determinism 163, screenshots
manifest 492 current, corpus 7/7, tools:contract green. Offline
screenshot baselines show expected mass drift from the engine bump —
re-baseline (screenshots:noise -> promote) is a follow-up.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016X9eh1s5sTx1o9Em9KBuwR
2026-08-13 17:41:28 +02:00

55 lines
2.4 KiB
TypeScript

import { test, expect } from '../e2e/utils/fixtures';
// Contract battery for the JSPI libcontext coroutine backend
// (kicad/thirdparty/libcontext/libcontext.cpp under PCBJAM_JSPI). The harness
// (tests/apps/standalone/jspi-coroutine) is a wx-free MiniCoro that mirrors
// tool/coroutine.h's protocol exactly — INVOCATION_ARGS, callerStub with the
// finish_fcontext hook, jumpIn/jumpOut, CONTINUE_AFTER_ROOT — over the real
// libcontext.cpp. 18 cases: create/run/finish, yield chains, nested
// call-in-call routed by enterer inference, RunMainStack payload propagation,
// ghost-resume refusal (dead tombstones, sentinel-shaped), mid-body release census, phantom-release refusal (running record + enterer chain), destroy-while-parked containment.
//
// Output contract: per-case "[JSPI_CORO] CASE <name> PASS|FAIL" then
// "[JSPI_CORO] SUMMARY passed=<n> failed=<n>".
const EXPECTED_PASSES = 18;
function findSummary(logs: string[]) {
return logs.find((l) => l.includes('[JSPI_CORO] SUMMARY'));
}
function assertSummary(logs: string[]) {
const summary = findSummary(logs)!;
const match = summary.match(/passed=(\d+)\s+failed=(\d+)/);
expect(match, `summary parseable: ${summary}`).not.toBeNull();
expect(Number(match![1]), 'all cases pass').toBe(EXPECTED_PASSES);
expect(Number(match![2]), 'no case fails').toBe(0);
const fails = logs.filter((l) => l.includes('[JSPI_CORO] CASE') && l.includes('FAIL'));
expect(fails, `FAIL cases: ${fails.join(' || ')}`).toHaveLength(0);
const fatal = logs.filter((l) => l.includes('[JSPI_CORO] FATAL'));
expect(fatal, `harness fatal: ${fatal.join(' || ')}`).toHaveLength(0);
}
test.describe('JSPI coroutine backend contract battery', () => {
test('single-thread build: 18/18 protocol cases pass', async ({ page, testLogger }) => {
await page.goto('/standalone/jspi-coroutine/');
await expect
.poll(() => findSummary(testLogger.consoleLogs) ?? null, {
timeout: 60000,
message: 'harness should emit its SUMMARY line',
})
.not.toBeNull();
assertSummary(testLogger.consoleLogs);
});
test('pthread build: 18/18 protocol cases pass', async ({ page, testLogger }) => {
await page.goto('/standalone/jspi-coroutine/?pt=1');
await expect
.poll(() => findSummary(testLogger.consoleLogs) ?? null, {
timeout: 60000,
message: 'pthread harness should emit its SUMMARY line',
})
.not.toBeNull();
assertSummary(testLogger.consoleLogs);
});
});