32 lines
2.8 KiB
JavaScript
32 lines
2.8 KiB
JavaScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import assert from 'node:assert/strict';
|
|
import { createHash } from 'node:crypto';
|
|
const prefix='.qa/embedded-browser-d-',read=file=>JSON.parse(fs.readFileSync(file));
|
|
const independent=read(prefix+'independent-continuation-result.json'),promotion=read(prefix+'promotion-result.json');
|
|
assert.equal(independent.success,true);assert.equal(promotion.success,true);
|
|
const consoleBytes=Buffer.concat([fs.readFileSync(prefix+'independent-console.log'),Buffer.from('\n'),fs.readFileSync(prefix+'independent-continuation-console.log')]);
|
|
const consoleEncoding=consoleBytes[0]===0xff&&consoleBytes[1]===0xfe?'utf16le':'utf8';
|
|
const consoleLines=(consoleEncoding==='utf16le'?consoleBytes.subarray(2):consoleBytes).toString(consoleEncoding).replace(/^\uFEFF/,'').split(/\r?\n/);
|
|
const pipeline=independent.completed.map(row=>{
|
|
const start=consoleLines.find(line=>line.startsWith('START '+row.name+' '));assert.ok(start);
|
|
const startedAt=start.slice(('START '+row.name+' ').length),durationMs=Date.parse(row.finishedAt)-Date.parse(startedAt);assert.ok(durationMs>=0);
|
|
return {name:row.name,startedAt,finishedAt:row.finishedAt,durationMs};
|
|
});
|
|
const formal=['stage','upgrade','activate','verify'].map(name=>{
|
|
const row=read(prefix+'formal-'+name+'.json');assert.equal(row.success,true);
|
|
return {name,startedAt:row.startedAt,finishedAt:row.finishedAt,durationMs:Date.parse(row.finishedAt)-Date.parse(row.startedAt)};
|
|
});
|
|
const manifestFile=path.join(independent.release.portableRoot,'MANIFEST.json'),manifestBytes=fs.readFileSync(manifestFile),manifest=JSON.parse(manifestBytes);
|
|
const sum=rows=>({files:rows.length,bytes:rows.reduce((total,row)=>total+row.bytes,0)});
|
|
const source=read(prefix+'source-original-result.json');
|
|
const testBatches=source.logs.filter(row=>/\b(?:tests-\d+|upgrade-tests)\.tap$/.test(row.path)).map(row=>{
|
|
const text=fs.readFileSync(row.path,'utf8'),duration=Number(text.match(/^# duration_ms ([\d.]+)\s*$/m)?.[1]);assert.ok(Number.isFinite(duration));
|
|
return {log:row.path,durationMs:duration,tests:Number(text.match(/^# tests (\d+)\s*$/m)?.[1]),pass:Number(text.match(/^# pass (\d+)\s*$/m)?.[1])};
|
|
});
|
|
const result={success:true,version:'1.22.0',createdAt:new Date().toISOString(),consoleEncoding,pipeline,formal,testBatches,
|
|
payload:{manifestSha256:createHash('sha256').update(manifestBytes).digest('hex'),all:sum(manifest.files),docs:sum(manifest.files.filter(row=>row.path.startsWith('docs/')))},
|
|
scope:'Observed phase wall-clock times, original TAP durations and immutable manifest byte totals. No directory-level runtime attribution or claimed performance improvement; original development failures remain separate.'};
|
|
fs.writeFileSync(prefix+'timing-review.json',JSON.stringify(result,null,2)+'\n',{flag:'wx'});
|
|
console.log(JSON.stringify({success:true,formal,payload:result.payload,testBatches:testBatches.length}));
|