Nothing measured what the tests reach. scripts/coverage.sh runs the cargo tests under cargo-llvm-cov in the ipx-coverage image (Dockerfile.coverage, built by build-image.sh coverage), in a container held to the image builder's 6 GB and six threads, one crate at a time, with the same room and load checks: an instrumented build rebuilds every dependency, the kind of build that took Tower down on 2026-11-04. The first run stayed under load 8 with 11 GB free; 69% of lines. web.rs and daemon.rs read low because the browser suite drives them against a daemon that is not instrumented. npm run coverage:page runs the browser suite on a build of the page (IPX_COVERAGE=1) whose script keeps a source map to each web/src file: web/concat-map.mts maps the joined files line by line and swc takes it as its input map. Each test's page records V8's coverage (tests/ui/coverage.ts, which the specs now take test and expect from), and monocart-coverage-reports writes it file by file: 73% of lines. build.mjs requires the map helper only for that build, since Dockerfile.web's Node does not run TypeScript, and not with a top-level await, which stopped the CommonJS tests requiring build.mjs. The offline tests move to offline.spec.ts, in TypeScript, and stand alone (they add their feed and set the read state they need), with what #391 found untested: another account signing in clears what was kept, a position saved offline waits and is sent, and pictures past the budget go oldest first (keepPictures takes the budget, and trims whether or not anything new came). The fixture JPEGs were a few bytes no browser could draw; they are real now, and the artwork test checks one draws. tsconfig.tools.json type-checks the tests' and build's TypeScript, in npm run typecheck. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
49
web/concat-map.mts
Normal file
49
web/concat-map.mts
Normal file
@@ -0,0 +1,49 @@
|
||||
// A source map for the page's script as web/build.mjs makes it, files joined one after another
|
||||
// (#390): each line of the joined script maps to its line in the file it came from. Given to swc
|
||||
// as the input map, the built script then maps to web/src/*.ts file by file, which is what the
|
||||
// coverage report needs. Only a coverage build uses it.
|
||||
|
||||
export interface SourceMap {
|
||||
version: 3;
|
||||
sources: string[];
|
||||
sourcesContent: string[];
|
||||
names: string[];
|
||||
mappings: string;
|
||||
}
|
||||
|
||||
const B64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
||||
|
||||
/// One number in a source map's base64 VLQ: sign in the lowest bit, five bits a digit.
|
||||
export function vlq(n: number): string {
|
||||
let v = n < 0 ? (-n << 1) | 1 : n << 1;
|
||||
let out = '';
|
||||
do {
|
||||
let digit = v & 31;
|
||||
v >>>= 5;
|
||||
if (v) digit |= 32;
|
||||
out += B64[digit];
|
||||
} while (v);
|
||||
return out;
|
||||
}
|
||||
|
||||
/// The map of `files` joined with '\n' between them, as build.mjs joins them.
|
||||
export function concatMap(files: { name: string; text: string }[]): SourceMap {
|
||||
const lines: string[] = [];
|
||||
// Each segment's fields are relative to the one before: source, line in it, column.
|
||||
let lastSource = 0, lastLine = 0;
|
||||
files.forEach((f, source) => {
|
||||
const count = f.text.split('\n').length;
|
||||
for (let line = 0; line < count; line++) {
|
||||
lines.push(vlq(0) + vlq(source - lastSource) + vlq(line - lastLine) + vlq(0));
|
||||
lastSource = source;
|
||||
lastLine = line;
|
||||
}
|
||||
});
|
||||
return {
|
||||
version: 3,
|
||||
sources: files.map((f) => f.name),
|
||||
sourcesContent: files.map((f) => f.text),
|
||||
names: [],
|
||||
mappings: lines.join(';'),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user