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,107 @@
|
||||
import { mkdirSync, writeFileSync } from 'node:fs'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { parseArgs } from 'node:util'
|
||||
import { checkBuild } from './app-build.mjs'
|
||||
import { hostFacts, memAvailableBytes } from './host.mjs'
|
||||
import { RESULTS_DIR } from './paths.mjs'
|
||||
import { ENGINES, loadPlaywright } from './playwright.mjs'
|
||||
import { markdownSummary } from './summary.mjs'
|
||||
import { watchdogFacts } from './watchdog.mjs'
|
||||
import { startServer } from '../serve.mjs'
|
||||
|
||||
/**
|
||||
* Shared CLI of the baseline scripts: checks the build, serves it, runs the
|
||||
* given sections (`{ export: fn, import: fn }`) engine after engine, writes
|
||||
* one results file and prints the summary tables.
|
||||
*/
|
||||
|
||||
const today = () => new Date().toISOString().slice(0, 10)
|
||||
const log = (line) => console.error(`[${new Date().toISOString()}] ${line}`)
|
||||
|
||||
const listOf = (text) => (text ? text.split(',').filter(Boolean) : null)
|
||||
|
||||
/** --reports and --groups narrow a run (null = all): reruns, smoke tests. */
|
||||
function options(defaultName) {
|
||||
const { values } = parseArgs({
|
||||
options: {
|
||||
engines: { type: 'string', default: ENGINES.join(',') },
|
||||
out: { type: 'string', default: join(RESULTS_DIR, defaultName) },
|
||||
reports: { type: 'string' },
|
||||
groups: { type: 'string' },
|
||||
},
|
||||
})
|
||||
const engines = listOf(values.engines)
|
||||
const unknown = engines.filter((e) => !ENGINES.includes(e))
|
||||
if (unknown.length) throw new Error(`unknown engines: ${unknown.join(', ')}`)
|
||||
const filters = {
|
||||
reports: listOf(values.reports),
|
||||
groups: listOf(values.groups),
|
||||
}
|
||||
return { engines, out: values.out, filters }
|
||||
}
|
||||
|
||||
/** Engine versions as the runs recorded them. */
|
||||
function enginesOf(sections) {
|
||||
const versions = {}
|
||||
for (const section of Object.values(sections)) {
|
||||
for (const run of section.runs ?? []) {
|
||||
if (run.engineVersion) versions[run.engine] = run.engineVersion
|
||||
}
|
||||
}
|
||||
return versions
|
||||
}
|
||||
|
||||
async function runSections(sections, context) {
|
||||
const results = {}
|
||||
for (const [name, run] of Object.entries(sections)) {
|
||||
log(`section ${name}: ${context.engines.join(', ')}`)
|
||||
results[name] = await run({ ...context, log })
|
||||
}
|
||||
return results
|
||||
}
|
||||
|
||||
/** What a results file states about the conditions of its runs. */
|
||||
function conditionsOf(build, playwrightCore, server) {
|
||||
return {
|
||||
harness: 'scripts/browser',
|
||||
startedAt: new Date().toISOString(),
|
||||
watchdog: watchdogFacts(),
|
||||
host: hostFacts(),
|
||||
build,
|
||||
server: { bind: '127.0.0.1', csp: server.csp, envJs: 'local tool' },
|
||||
playwrightCore,
|
||||
}
|
||||
}
|
||||
|
||||
function writeResult(out, result) {
|
||||
mkdirSync(dirname(out), { recursive: true })
|
||||
writeFileSync(out, `${JSON.stringify(result, null, 2)}\n`)
|
||||
log(`results written to ${out}`)
|
||||
console.log(markdownSummary(result))
|
||||
}
|
||||
|
||||
export async function runHarnessCli(sections, defaultName) {
|
||||
const sectionNames = Object.keys(sections).join('-')
|
||||
const { engines, out, filters } = options(
|
||||
defaultName ?? `${today()}-${sectionNames}.json`,
|
||||
)
|
||||
const build = checkBuild()
|
||||
const { pw, version } = loadPlaywright()
|
||||
const server = await startServer()
|
||||
try {
|
||||
const conditions = conditionsOf(build, version, server)
|
||||
const context = { pw, baseUrl: server.url, engines, filters }
|
||||
const results = await runSections(sections, context)
|
||||
conditions.host.memAvailableBytesAtEnd = memAvailableBytes()
|
||||
const endedAt = new Date().toISOString()
|
||||
const engineVersions = enginesOf(results)
|
||||
writeResult(out, {
|
||||
...conditions,
|
||||
endedAt,
|
||||
engines: engineVersions,
|
||||
...results,
|
||||
})
|
||||
} finally {
|
||||
server.close()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user