29 lines
2.4 KiB
JavaScript
29 lines
2.4 KiB
JavaScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import assert from 'node:assert/strict';
|
|
import { spawn } from 'node:child_process';
|
|
import { pathToFileURL } from 'node:url';
|
|
import { createHash } from 'node:crypto';
|
|
import { projectEnvironment } from '../src/core/process-environment.mjs';
|
|
const prefix = '.qa/embedded-browser-b-', root = 'D:/AWQA22/s-e996eb71';
|
|
const read = file => JSON.parse(fs.readFileSync(file));
|
|
const hash = bytes => createHash('sha256').update(bytes).digest('hex');
|
|
console.log('Wait for original source verification to finish before running a bounded diagnostic; no promotion or result replacement.');
|
|
while (!fs.existsSync(prefix + 'source-receipt.json')) await new Promise(resolve => setTimeout(resolve, 2000));
|
|
assert.equal(read(prefix + 'source-receipt.json').exitCode, 1);
|
|
const input = path.join(root, 'tests/workers-http.test.mjs'), originalSha256 = hash(fs.readFileSync(input));
|
|
assert.equal(originalSha256, hash(fs.readFileSync('tests/workers-http.test.mjs')));
|
|
const log = prefix + 'http-diagnostic.tap', stream = fs.createWriteStream(log, { flags: 'wx' });
|
|
const args = ['--import', pathToFileURL(path.join(root, '.qa/worker-http-observer.mjs')).href, '--test', '--test-concurrency=2', '--test-reporter=tap', 'tests/workers-http.test.mjs'];
|
|
const child = spawn(process.execPath, args, { cwd: root, env: projectEnvironment(), windowsHide: true, stdio: ['ignore','pipe','pipe'] });
|
|
child.stdout.pipe(stream, { end: false }); child.stderr.pipe(stream, { end: false });
|
|
const timer = setTimeout(() => child.kill(), 180000);
|
|
const exitCode = await new Promise((resolve, reject) => { child.once('error', reject); child.once('close', resolve); }); clearTimeout(timer);
|
|
await new Promise(resolve => stream.end(resolve));
|
|
assert.equal(hash(fs.readFileSync(input)), originalSha256);
|
|
const state = prefix + 'http-diagnostic-state.json';
|
|
const result = { completed: true, exitCode, args, cwd: root, testSha256: originalSha256, log, logSha256: hash(fs.readFileSync(log)), state: fs.existsSync(state) ? { path: state, sha256: hash(fs.readFileSync(state)) } : null,
|
|
scope: 'Diagnostic only. Same original HTTP tests and 20-second deadline, with in-memory status observer. Original B source result remains failed; no source, archive, installation, or formal action is performed.' };
|
|
fs.writeFileSync(prefix + 'http-diagnostic-result.json', JSON.stringify(result, null, 2) + '\n', { flag: 'wx' });
|
|
console.log(JSON.stringify(result));
|