import fs from 'node:fs'; import path from 'node:path'; import assert from 'node:assert/strict'; import { spawn } from 'node:child_process'; import { projectEnvironment } from '../../src/core/process-environment.mjs'; const root=path.resolve('.qa/reliability-1.25.2'); const read=file=>JSON.parse(fs.readFileSync(path.join(root,file),'utf8')); const before=read('release/freeze.json'),after=read('release-final/freeze.json'); assert.deepEqual(before.compiled,after.compiled,'Tests/docs revision must not alter any compiled product bytes.'); const changes=after.inputs.filter(row=>before.inputs.find(old=>old.path===row.path)?.sha256!==row.sha256); assert.deepEqual(changes.map(row=>row.path),['tests/network-diagnostics.test.mjs']); fs.writeFileSync(path.join(root,'candidate-input-delta.json'),JSON.stringify({success:true,before:before.sourceCommit,after:after.sourceCommit,changes,compiledExact:22,productInputsUnchanged:true},null,2)+'\n',{flag:'wx'}); const wait=ms=>new Promise(resolve=>setTimeout(resolve,ms)); async function until(predicate,label,timeout=70*60000){const deadline=Date.now()+timeout;while(!predicate()){assert.ok(Date.now(){const child=spawn(process.execPath,[path.join(root,'release-runner.mjs'),name,'release-final'],{windowsHide:true,env:projectEnvironment(),stdio:['ignore','inherit','inherit']});child.once('error',reject);child.once('close',resolve);});assert.equal(code,0,'Inspect immutable '+name+' receipt before resuming.'); } await until(()=>{try{return JSON.parse(fs.readFileSync('releases/latest.json')).documentation.sourceCommit===after.sourceCommit;}catch{return false;}},'Packaging did not complete'); for(const name of ['register','rebuild','archives'])await stage(name); console.log('WAIT exact complete source suite before portable and installer acceptance'); await until(()=>fs.readFileSync(path.join(root,'full-release-final.tap'),'utf8').includes('duration_ms'),'Full source suite did not complete'); const suite=fs.readFileSync(path.join(root,'full-release-final.tap'),'utf8'); for(const pattern of [/\btests 899\b/,/\bpass 899\b/,/\bfail 0\b/,/\bcancelled 0\b/,/\bskipped 0\b/])assert.match(suite,pattern); for(const name of ['portable','install','portable-a','portable-a-desktop','portable-b','portable-b-desktop','portable-c','portable-c-desktop','portable-d','portable-d-desktop','portable-files','portable-results','portable-reading'])await stage(name); console.log(JSON.stringify({success:true,sourceCommit:after.sourceCommit,stages:16,realModelRequests:0,formalTouched:false}));