22 lines
1.9 KiB
Plaintext
22 lines
1.9 KiB
Plaintext
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import {execFileSync} from 'node:child_process';
|
|
import {isDeepStrictEqual} from 'node:util';
|
|
import assert from 'node:assert/strict';
|
|
import {validateInstalledVersion} from '../../src/core/desktop/install-manager.mjs';
|
|
import {inspectHostInstallation} from '../../src/core/desktop/app-installation.mjs';
|
|
import {readState,ownedChild} from '../../src/core/desktop/file-state.mjs';
|
|
import {hostError} from '../../src/shared/contracts/desktop-host.mjs';
|
|
const source=execFileSync('git',['show','532b9d60:src/core/desktop/install-manager.mjs'],{encoding:'utf8'});
|
|
const code=source.slice(source.indexOf('export function validateInstalledVersion('),source.indexOf('export function snapshotPersistentData('));
|
|
const previous=new Function('inspectHostInstallation','readState','fs','path','fail','ownedChild','isDeepStrictEqual',code.replace('export function validateInstalledVersion','function validateInstalledVersion')+'\nreturn validateInstalledVersion;')
|
|
(inspectHostInstallation,readState,fs,path,message=>hostError(message,'INSTALLATION_REJECTED',409),ownedChild,isDeepStrictEqual);
|
|
const receipt=JSON.parse(fs.readFileSync('.qa/outlier-release/formal-attempt-2/final.json','utf8'));
|
|
const rows=[];let identity;
|
|
for(const [name,validate] of [['before',previous],['after',validateInstalledVersion],['after',validateInstalledVersion],['before',previous]]){
|
|
const start=performance.now(),actual=validate(receipt.runtimeRoot);if(identity)assert.deepEqual(actual,identity);else identity=actual;
|
|
rows.push({name,elapsedMs:Math.round(performance.now()-start)});
|
|
}
|
|
const result={success:true,readOnly:true,candidate:receipt.runtimeRoot,manifestFiles:JSON.parse(fs.readFileSync(path.join(receipt.runtimeRoot,'MANIFEST.json'),'utf8')).files.length,rows,identitiesExact:true};
|
|
fs.writeFileSync('.qa/reliability-1.25.2/install-benchmark.json',JSON.stringify(result,null,2)+'\n');console.log(JSON.stringify(result));
|