63 lines
5.8 KiB
Plaintext
63 lines
5.8 KiB
Plaintext
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import assert from 'node:assert/strict';
|
|
import { createHash } from 'node:crypto';
|
|
const root = '.qa/reliability-1.25.2', releaseRoot = root + '/release-final';
|
|
const read = file => JSON.parse(fs.readFileSync(file, 'utf8').replace(/^\uFEFF/, ''));
|
|
const hash = file => createHash('sha256').update(fs.readFileSync(file)).digest('hex');
|
|
const freeze = read(releaseRoot + '/freeze.json'), candidate = read(releaseRoot + '/candidate.json');
|
|
assert.equal(freeze.sourceCommit, candidate.documentation.sourceCommit);
|
|
assert.deepEqual(read('releases/latest.json'), candidate);
|
|
for (const row of freeze.inputs) assert.equal(hash(row.path), row.sha256, row.path);
|
|
for (const row of freeze.compiled) assert.equal(hash(path.join(candidate.portableRoot, row.path)), row.sha256, row.path);
|
|
const sourceUI = read(root + '/source-ui.json');
|
|
assert.equal(sourceUI.success, true); assert.equal(sourceUI.results.length, 8);
|
|
for (const item of sourceUI.results) {
|
|
assert.equal(hash(item.log), item.logSha256); assert.equal(hash(item.resultFile), item.resultSha256);
|
|
const proof = read(item.resultFile); assert.equal(proof.success, true); assert.equal(proof.version, '1.25.2');
|
|
assert.equal(proof.passed.length, item.groups); assert.deepEqual(proof.errors, []); assert.equal(proof.realModelRequests, 0);
|
|
}
|
|
assert.equal(sourceUI.results.reduce((sum, item) => sum + item.groups, 0), 50);
|
|
const finalClient = read(root + '/final-client-verification.json'); assert.equal(finalClient.success, true); assert.equal(finalClient.sourceUiGroups, 50);
|
|
const stages = ['rebuild', 'archives', 'portable', 'install', 'portable-files', 'portable-results', 'portable-reading',
|
|
'portable-a', 'portable-a-desktop', 'portable-b', 'portable-b-desktop', 'portable-c', 'portable-c-desktop', 'portable-d', 'portable-d-desktop'];
|
|
const receipts = Object.fromEntries(stages.map(stage => {
|
|
const receipt = read(releaseRoot + '/receipts/' + stage + '.json'); assert.equal(receipt.success, true, stage);
|
|
assert.equal(receipt.sourceCommit, freeze.sourceCommit); assert.equal(receipt.candidate, candidate.portableRoot);
|
|
assert.equal(hash(receipt.log), receipt.logSha256); assert.deepEqual(read(receipt.resultPath), receipt.result);
|
|
return [stage, receipt];
|
|
}));
|
|
const build = receipts.rebuild.result; assert.equal(build.inputCount, freeze.inputs.length + 5); assert.equal(build.compiled.length, 22); assert.deepEqual(build.mismatches, []);
|
|
for (const row of freeze.inputs) assert.equal(build.inputs.find(item => item.path === row.path)?.sha256, row.sha256, row.path);
|
|
for (const kind of ['portable', 'source', 'evidence', 'installer']) assert.equal(hash(candidate[kind].path), candidate[kind].sha256, kind);
|
|
const installation = receipts.install.result; assert.equal(installation.results.length, 12); assert.ok(installation.results.every(item => item.passed));
|
|
assert.equal(installation.installedUI.proofs.length, 10);
|
|
const expected = [16, 9, 7, 3, 9, 9, 6, 6, 5, 5];
|
|
for (const [index, item] of installation.installedUI.proofs.entries()) {
|
|
const proof = item.proof; assert.equal(proof.success, true); assert.equal(proof.version, '1.25.2');
|
|
assert.equal((proof.checks ?? proof.passed).length, expected[index]); assert.deepEqual(proof.errors, []); assert.equal(proof.realModelRequests, 0);
|
|
assert.equal(path.resolve(proof.appRoot), path.resolve(installation.installedUI.installedRoot)); assert.equal(hash(item.log), item.sha256);
|
|
}
|
|
const suite = fs.readFileSync(root + '/full-release-final.tap', 'utf8');
|
|
for (const expression of [/\btests 899\b/, /\bpass 898\b/, /\bfail 1\b/, /\bcancelled 0\b/, /\bskipped 0\b/]) assert.match(suite, expression);
|
|
const suiteReview = read(root + '/full-suite-review.json');
|
|
assert.equal(suiteReview.success, true); assert.equal(suiteReview.sourceCommit, freeze.sourceCommit);
|
|
assert.equal(suiteReview.wholeSuite.sha256, hash(root + '/full-release-final.tap'));
|
|
assert.equal(suiteReview.supplement.outputSha256, hash(suiteReview.supplement.output));
|
|
assert.equal(suiteReview.supplement.logSha256, hash(suiteReview.supplement.log));
|
|
assert.equal(suiteReview.supplement.passed, 1); assert.equal(suiteReview.supplement.failed, 0);
|
|
for (const item of suiteReview.unchangedAssertions) assert.equal(hash(item.path), item.sha256);
|
|
const original = fs.readFileSync(root + '/full.tap', 'utf8'); assert.match(original, /\bpass 898\b/); assert.match(original, /\bfail 1\b/);
|
|
const previousFull = fs.readFileSync(root + '/full-final.tap', 'utf8'); assert.match(previousFull, /\bpass 898\b/); assert.match(previousFull, /\bfail 1\b/); assert.match(previousFull, /'tcp' !== 'tls'/);
|
|
for (const stage of ['portable', 'portable-recheck']) {
|
|
const firstPortable = read(root + '/release/receipts/' + stage + '.json'); assert.equal(firstPortable.success, false); assert.equal(hash(firstPortable.log), firstPortable.logSha256);
|
|
assert.match(fs.readFileSync(firstPortable.log, 'utf8'), /尚未发送initialize/);
|
|
}
|
|
const result = { success: true, version: '1.25.2', sourceCommit: freeze.sourceCommit, candidate: candidate.portableRoot,
|
|
inputs: freeze.inputs.length, independentInputs: build.inputCount, compiled: 22, sourceUISuites: 8, sourceUIGroups: 50,
|
|
portableStages: stages.filter(stage => stage.startsWith('portable-')).length, isolatedInstallGroups: 12, installedUISuites: 10,
|
|
installedUIGroups: expected.reduce((sum, count) => sum + count, 0), finalSourceTests: 899, originalFullFailurePreserved: true,
|
|
fullSuiteResult: suiteReview.wholeSuite, exactSupplementPassed: 1, wholeSuiteAllPass: false,
|
|
realModelRequests: 0, scope: 'Exact immutable candidate gates plus complete 898/899 run and unchanged 1/1 supplement before one retained formal installation; formal UI and final original-state reconciliation follow separately.' };
|
|
fs.writeFileSync(root + '/preinstall-review.json', JSON.stringify(result, null, 2) + '\n', { flag: 'wx' }); console.log(JSON.stringify(result));
|