test(tests): R4.1e browser harness and TS baselines (Chromium, Firefox, WebKit)
Playwright harness under scripts/browser: 127.0.0.1 server with the DEPLOY CSP, export and import baselines of the TypeScript engine under a 4 GiB RSS watchdog (not a guaranteed memory limit), O9 browser columns in inflate.browsers.json (26 rows agree with Node in all three engines). Results of 2026-10-18 committed; the O9 Node test no longer expects browser columns in inflate.json.
This commit is contained in:
1 parent
4bdfda59ba
commit
4439fd2420
23 files changed
+20903
-18
No files matched your search
@@ -0,0 +1,52 @@
|
||||
import { createHash } from 'node:crypto'
|
||||
import { readFileSync, readdirSync, statSync } from 'node:fs'
|
||||
import { dirname, join, resolve } from 'node:path'
|
||||
|
||||
/**
|
||||
* Fixture files, and the R4 oracle inputs committed as generator
|
||||
* descriptions (`<slug>.gen.json`, generator `concat/1`, written by
|
||||
* packages/pdf/tests/helpers/r4-reader-io.ts for inputs over 2 MiB).
|
||||
*/
|
||||
|
||||
export const sha256 = (bytes) =>
|
||||
createHash('sha256').update(bytes).digest('hex')
|
||||
|
||||
/** Files under `dir`, sorted, recursively when asked. */
|
||||
export function filesUnder(dir, recursive = false) {
|
||||
const files = []
|
||||
for (const name of readdirSync(dir).sort()) {
|
||||
const path = join(dir, name)
|
||||
if (statSync(path).isDirectory()) {
|
||||
if (recursive) files.push(...filesUnder(path, true))
|
||||
} else {
|
||||
files.push(path)
|
||||
}
|
||||
}
|
||||
return files
|
||||
}
|
||||
|
||||
export const isGenerator = (path) => path.endsWith('.gen.json')
|
||||
|
||||
function partBytes(part, dir) {
|
||||
if ('latin1' in part) return Buffer.from(part.latin1, 'latin1')
|
||||
if ('fill' in part) return Buffer.alloc(part.count, part.fill)
|
||||
const source = readFileSync(resolve(dir, part.slice))
|
||||
return source.subarray(part.start, part.end)
|
||||
}
|
||||
|
||||
/** The bytes a description stands for, checked: length and digest. */
|
||||
export function expandGenerator(path) {
|
||||
const description = JSON.parse(readFileSync(path, 'utf8'))
|
||||
if (description.generator !== 'concat/1') {
|
||||
throw new Error(`${path}: unknown generator ${description.generator}`)
|
||||
}
|
||||
const parts = description.parts.map((p) => partBytes(p, dirname(path)))
|
||||
const bytes = Buffer.concat(parts)
|
||||
if (bytes.length !== description.length) {
|
||||
throw new Error(`${path}: expands to ${bytes.length} bytes`)
|
||||
}
|
||||
if (sha256(bytes) !== description.sha256) {
|
||||
throw new Error(`${path}: digest differs from the description`)
|
||||
}
|
||||
return bytes
|
||||
}
|
||||
Reference in new issue
Block a user