25 lines
2.9 KiB
JavaScript
25 lines
2.9 KiB
JavaScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
const prefix = '.qa/embedded-browser-d-';
|
|
const read = file => fs.existsSync(file) ? JSON.parse(fs.readFileSync(file)) : null;
|
|
function log(file) {
|
|
if (!fs.existsSync(file)) return '';
|
|
const bytes = fs.readFileSync(file);
|
|
return bytes[0] === 0xff && bytes[1] === 0xfe ? bytes.subarray(2).toString('utf16le') : bytes.toString('utf8').replace(/^\uFEFF/, '');
|
|
}
|
|
const originalIndependent = read(prefix + 'independent-result.json'), continuationStarted = fs.existsSync(prefix+'independent-continuation-console.log');
|
|
const independent = read(prefix + 'independent-continuation-result.json') ?? (continuationStarted ? null : originalIndependent), promotion = read(prefix + 'promotion-result.json');
|
|
const sourceText = log(prefix + 'source.log'), sourceStart = sourceText.split(/\r?\n/).find(line => line.startsWith('{"sourceRoot":'));
|
|
const source = sourceStart ? JSON.parse(sourceStart) : null;
|
|
const batches = source && fs.existsSync(source.directory) ? fs.readdirSync(source.directory).filter(name => /^(?:tests-\d+|upgrade-tests)\.tap$/.test(name)).sort().map(name => {
|
|
const text = log(path.join(source.directory, name));
|
|
const total = text.match(/^# tests (\d+)\s*$/m), pass = text.match(/^# pass (\d+)\s*$/m), fail = text.match(/^# fail (\d+)\s*$/m);
|
|
return { name, complete: !!total && !!pass && !!fail, tests: total ? Number(total[1]) : null, pass: pass ? Number(pass[1]) : null, fail: fail ? Number(fail[1]) : null, observedPassedTopLevel: (text.match(/^ok \d+ /gm) ?? []).length, observedFailedTopLevel: (text.match(/^not ok \d+ /gm) ?? []).length };
|
|
}) : [];
|
|
const complete = batches.filter(row => row.complete);
|
|
const activePhase = ((log(prefix + 'independent-console.log')+'\n'+log(prefix+'independent-continuation-console.log')).match(/^START .+$/gm) ?? []).at(-1) ?? null;
|
|
const promotionPhase = (log(prefix + 'promotion-console.log').match(/^START .+$/gm) ?? []).at(-1) ?? null;
|
|
console.log(JSON.stringify({ at: new Date().toISOString(), originalDRejectedAcceptance:originalIndependent?.success===false, continuationStarted, coreTestExecution:'C complete passing run inherited after strict input binding; not re-executed by D', independent: independent ? { success: independent.success, completed: independent.completed.length, error: independent.error } : { running: true, activePhase },
|
|
source: source ? { root: source.sourceRoot, stage: (sourceText.match(/^Source package: .+$/gm) ?? []).at(-1), completedBatches: complete.length, completeTests: complete.reduce((sum, row) => sum + row.tests, 0), completePassed: complete.reduce((sum, row) => sum + row.pass, 0), completeFailed: complete.reduce((sum, row) => sum + row.fail, 0), latest: batches.slice(-2) } : null,
|
|
promotion: promotion ? { success: promotion.success, completed: promotion.completed.map(row => row.name), error: promotion.error } : { waitingOrRunning: true, phase: promotionPhase }, realModelRequestsInitiated: 0 }));
|