28 lines
1.5 KiB
JavaScript
28 lines
1.5 KiB
JavaScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { spawn } from 'node:child_process';
|
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
const output = path.join(root,'docs/current/user-tests-20260915',`repair-checks-${new Date().toISOString().replace(/[:.]/g,'-')}`);
|
|
fs.mkdirSync(output,{recursive:true});
|
|
const checks = [
|
|
['display-contract',['node','--test','tools/test-document-display-persistence.mjs']],
|
|
['window-contract',['node','--test','tools/test-window-host-contract.mjs']],
|
|
['geometry-boundary',['npm','run','check:geometry-boundary']],
|
|
['production-build',['npm','run','build']],
|
|
];
|
|
const results=[];
|
|
for(const [name,[command,...args]] of checks) {
|
|
const start=performance.now(); const log=fs.openSync(path.join(output,`${name}.log`),'w');
|
|
const child=spawn(command,args,{cwd:path.join(root,'web'),env:{...process.env,FREECAD_WEB_FAST_LINK:'ON'},stdio:['ignore',log,log]});
|
|
let timedOut=false;
|
|
const timer=setTimeout(()=>{timedOut=true;child.kill('SIGTERM');},300000);
|
|
const exitCode=await new Promise(resolve=>{child.once('error',()=>resolve(-1));child.once('close',resolve);});
|
|
clearTimeout(timer);fs.closeSync(log);
|
|
results.push({name,command:[command,...args],exitCode,timedOut,seconds:Number(((performance.now()-start)/1000).toFixed(3))});
|
|
fs.writeFileSync(path.join(output,'results.json'),JSON.stringify(results,null,2)+'\n');
|
|
console.log(JSON.stringify(results.at(-1)));
|
|
}
|
|
console.log(output);
|
|
process.exitCode=results.every(r=>r.exitCode===0)?0:1;
|