Coverage measures the page's Node tests and runs the Rust on Postgres (#407)

page-unit.ts and native-bridge.ts run the page's script outside a
browser, so the page's coverage counted none of what they test, and
native.ts read as mostly untested. In a coverage run they now run the
script from a file of its own, named as the browser names it, under
NODE_V8_COVERAGE (scripts/coverage-node.sh, before the browser suite in
npm run coverage:page and coverage.sh api), and the report's teardown
takes their record in, mapped to web/src by the build's source map: the
page's lines went from 73.3% to 80.0% of 3,043, native.ts to 93 of 120.

The cargo tests in coverage.sh's container run on Postgres, as
production does, when IPX_TEST_DATABASE_URL names the _test database,
from the shell or else /src/.envrc (that variable only); on SQLite
without it. The integration tests' own files are left out of the
totals; a crate's inline mod tests cannot be on stable Rust.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-07 04:57:32 +00:00
parent 7994f93f31
commit f6ba08d506
7 changed files with 56 additions and 11 deletions

View File

@@ -7,7 +7,7 @@
// road, with nothing to look at.
//
// node tests/native-bridge.ts
import { makeContext, vm } from './dom-stub.ts';
import { makeContext, vm, scriptName } from './dom-stub.ts';
import { buildPage } from '../web/build.mts';
const { html, js: script } = buildPage('index.html');
@@ -19,7 +19,7 @@ const ok = (cond: unknown, what: string) => { if (!cond) { console.error('FAIL:
{
const { ctx } = makeContext(html, script, { media: true });
vm.createContext(ctx);
vm.runInContext(script, ctx, { filename: 'browser', timeout: 5000 });
vm.runInContext(script, ctx, { filename: scriptName(script, 'browser'), timeout: 5000 });
ok(ctx.window.ipxNative === undefined, 'the bridge installed in a plain browser');
const audio = ctx.document.querySelector('#audio');
audio.src = '/media/1';
@@ -35,7 +35,7 @@ if (!media) throw new Error('makeContext gave no media element for { media: true
const audio = media;
ctx.window.webkit = { messageHandlers: { ipx: { postMessage: (m: Posted) => posted.push(m) } } };
vm.createContext(ctx);
vm.runInContext(script, ctx, { filename: 'shell', timeout: 5000 });
vm.runInContext(script, ctx, { filename: scriptName(script, 'shell'), timeout: 5000 });
const last = (t: string) => [...posted].reverse().find(m => m.t === t);
const since = () => posted.splice(0, posted.length);