49 lines
5.1 KiB
JavaScript
49 lines
5.1 KiB
JavaScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import assert from 'node:assert/strict';
|
|
import { createHash } from 'node:crypto';
|
|
const read = file => JSON.parse(fs.readFileSync(file)), hash = bytes => createHash('sha256').update(bytes).digest('hex');
|
|
const root = 'docs/embedded-browser-rejected-candidate-evidence'; assert.equal(fs.existsSync(root), false);
|
|
const independent = read('.qa/embedded-browser-independent-result.json'), source = read('.qa/embedded-browser-source-original-result.json');
|
|
assert.equal(independent.success, false); assert.equal(source.success, false); assert.equal(source.stage, 'actual contained Electron window');
|
|
const files = [], pending = [];
|
|
function copy(file, relative) {
|
|
if (files.some(row => row.path === relative)) return;
|
|
const bytes = fs.readFileSync(file); pending.push({ file: path.join(root, relative), bytes });
|
|
files.push({ path: relative, source: file, bytes: bytes.length, sha256: hash(bytes) });
|
|
}
|
|
for (const name of ['code-baseline', 'independent-result', 'source-original-result', 'archives-original-result', 'source-receipt', 'source-short-path', 'promotion-result', 'all-ui-original-result', 'ui-evidence-preflight']) copy('.qa/embedded-browser-' + name + '.json', 'receipts/' + name + '.json');
|
|
for (const name of ['independent-console', 'all-ui', 'source', 'promotion-console', 'package', 'archives']) copy('.qa/embedded-browser-' + name + '.log', 'pipeline/' + name + '.log');
|
|
for (const row of source.logs) { assert.equal(hash(fs.readFileSync(row.path)), row.sha256); copy(row.path, 'source/' + path.basename(row.path)); }
|
|
copy(path.join(source.directory, 'test-plan.json'), 'source/test-plan.json');
|
|
for (const name of ['desktop-window-latest', 'embedded-browser-latest']) {
|
|
const file = path.join(source.sourceRoot, '.qa', name + '.json'), value = read(file); copy(file, name + '/result.json');
|
|
const directory = value.root ?? value.directory;
|
|
if (directory) for (const entry of fs.readdirSync(directory, { withFileTypes: true })) if (entry.isFile() && /\.(?:png|jpg|html|json)$/.test(entry.name) && entry.name !== 'result.json') copy(path.join(directory, entry.name), name + '/' + entry.name);
|
|
}
|
|
const allUi = read('.qa/embedded-browser-all-ui-validation.json'); assert.equal(allUi.success, true); assert.equal(allUi.groups, 250);
|
|
copy('.qa/embedded-browser-all-ui-validation.json', 'all-ui/result.json');
|
|
for (const row of allUi.results) {
|
|
const name = path.basename(row.script, '.mjs'); copy(row.evidence, 'all-ui/' + name + '.json'); copy(row.log, 'all-ui/' + name + '.log');
|
|
const value = read(row.evidence), output = fs.readFileSync(row.log, 'utf8');
|
|
const directory = value.directory ?? [...output.matchAll(/^EVIDENCE (.+)\r?$/gm)].at(-1)?.[1]?.trim() ?? value.root;
|
|
for (const item of Array.isArray(value.screenshots) ? value.screenshots : []) {
|
|
const declared = typeof item === 'string' ? item : item.file ?? item.path ?? item.screenshot;
|
|
const file = fs.existsSync(declared) ? declared : path.join(directory, declared), bytes = fs.readFileSync(file), expected = item.sha256 ?? item.screenshotSha256;
|
|
if (expected) assert.equal(hash(bytes), expected); copy(file, 'all-ui/' + name + '/' + path.basename(file));
|
|
}
|
|
}
|
|
const release = read('releases/latest.json'); copy('releases/latest.json', 'release.json');
|
|
copy(path.join(release.portableRoot, 'MANIFEST.json'), 'portable-manifest.json'); copy(path.join(release.sourceRoot, 'MANIFEST.json'), 'source-manifest.json');
|
|
copy('scripts/verify-desktop-window.mjs', 'review/original-verify-desktop-window.mjs');
|
|
copy('.qa/seal-embedded-browser-rejected.mjs', 'review/sealer.mjs');
|
|
const testLogs = source.logs.filter(row => /(?:tests-\d+|upgrade-tests)\.tap$/.test(row.path));
|
|
const stats = testLogs.map(row => { const text = fs.readFileSync(row.path, 'utf8'); return Object.fromEntries(['tests', 'pass', 'fail', 'cancelled', 'skipped', 'todo'].map(key => [key, Number(text.match(new RegExp('^# ' + key + ' (\\d+)\\s*$', 'm'))?.[1])])); });
|
|
const tests = Object.fromEntries(['tests', 'pass', 'fail', 'cancelled', 'skipped', 'todo'].map(key => [key, stats.reduce((sum, row) => sum + row[key], 0)]));
|
|
assert.equal(tests.tests, 683); assert.equal(tests.pass, 683); assert.equal(tests.fail, 0);
|
|
const result = { schemaVersion: 1, version: '1.22.0', kind: 'rejected-candidate-A', sourceCommit: independent.codeCommit, tests, sourceOverallSuccess: false, allUiGroups: allUi.groups, files, bytes: files.reduce((sum, row) => sum + row.bytes, 0), realModelRequests: 0,
|
|
reason: 'Actual desktop-window verifier still expected old strict preload method list and rejected the legitimate newly scoped browsingLayout method. Production promotion halted before any formal phase. Original 683 passing tests and separate 250 UI groups remain valid within their original scope; source overall failure is retained.' };
|
|
fs.mkdirSync(root); for (const item of pending) { fs.mkdirSync(path.dirname(item.file), { recursive: true }); fs.writeFileSync(item.file, item.bytes, { flag: 'wx' }); }
|
|
fs.writeFileSync(root + '/manifest.json', JSON.stringify(result, null, 2) + '\n', { flag: 'wx' });
|
|
console.log(JSON.stringify({ success: true, files: files.length, bytes: result.bytes, tests, sourceOverallSuccess: false }));
|