commit15
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import crypto from 'node:crypto';
|
||||
import {spawnSync} from 'node:child_process';
|
||||
const root='C:/laragon/data/sgf-tempo/run';
|
||||
if(process.argv[2] && !['plans','access','fanout','concurrency','release','http-lock'].includes(process.argv[2]))throw Error('Use no argument, plans, access, fanout, concurrency, release or http-lock');
|
||||
const plans=process.argv[2]==='plans';
|
||||
const access=process.argv[2]==='access';
|
||||
const fanout=process.argv[2]==='fanout';
|
||||
const concurrency=process.argv[2]==='concurrency';
|
||||
const release=process.argv[2]==='release';
|
||||
const httpLock=process.argv[2]==='http-lock';
|
||||
const state=JSON.parse(fs.readFileSync(path.join(root,'modular-regression-current.json'),'utf8'));
|
||||
if(!/^[a-f0-9]{12}$/.test(state.id)||path.resolve(state.root)!==path.resolve(root,'modular-regression-'+state.id)||path.resolve(state.app)!==path.resolve(state.root,'app')||state.port!==55439)throw Error('Unexpected isolated host');
|
||||
if(fanout){
|
||||
const before=fs.readFileSync(path.join(state.root,'pre-projection-review.php'),'utf8');
|
||||
const expected=fs.readFileSync(path.join(state.root,'pre-projection-sha256.txt'),'utf8').trim();
|
||||
const recovered=before.replace('final class PreProjectionModuleAssociationReview','final class ModuleAssociationReview');
|
||||
if(!before.includes('final class PreProjectionModuleAssociationReview')||crypto.createHash('sha256').update(recovered).digest('hex')!==expected)throw Error('Pre-projection baseline integrity mismatch');
|
||||
}
|
||||
const old=spawnSync('git',['show','340f3bb:app/Modules/Identity/Services/ModuleAssociationReview.php'],{encoding:'utf8',windowsHide:true});
|
||||
if(old.status!==0||!old.stdout.includes('final class ModuleAssociationReview'))throw Error('Cannot recover the accepted baseline');
|
||||
const baselineSha=crypto.createHash('sha256').update(old.stdout).digest('hex');
|
||||
const optimizedSha=crypto.createHash('sha256').update(fs.readFileSync(path.join(state.app,'app/Modules/Identity/Services/ModuleAssociationReview.php'))).digest('hex');
|
||||
fs.writeFileSync(path.join(state.root,'baseline-review.php'),old.stdout.replace('final class ModuleAssociationReview','final class BaselineModuleAssociationReview'));
|
||||
const output=path.join(state.root,(plans?'association-index-plans-':access?'association-access-parity-':fanout?'association-fanout-':concurrency?'association-concurrency-':release?'association-release-':httpLock?'association-http-lock-':'association-compare-')+Date.now()+'.json');
|
||||
const test=plans?'ModuleAssociationIndexPlanTest.php':access?'ModuleAssociationAccessParityTest.php':fanout?'ModuleAssociationFanoutTest.php':concurrency?'ModuleAssociationConcurrencyTest.php':release?'ModuleAssociationReleaseTest.php':httpLock?'ModuleAssociationHttpLockTest.php':'ModuleAssociationCompareTest.php';
|
||||
const result=spawnSync('C:/laragon/tools/sgf-tempo/php-8.4.27/php.exe',['vendor/phpunit/phpunit/phpunit','scripts/benchmarks/'+test,'--log-junit',output.replace('.json','.xml')],{
|
||||
cwd:state.app,stdio:'inherit',windowsHide:true,env:{...process.env,SGF_ISOLATED_REGRESSION_RUN:state.id,SGF_ASSOCIATION_LOAD_OUTPUT:output,SGF_ASSOCIATION_BASELINE_SHA:baselineSha,SGF_ASSOCIATION_OPTIMIZED_SHA:optimizedSha},
|
||||
});
|
||||
console.log(JSON.stringify({exit_code:result.status,report:output,baseline_sha256:baselineSha}));process.exitCode=result.status??1;
|
||||
Reference in New Issue
Block a user