17 lines
1.1 KiB
JavaScript
17 lines
1.1 KiB
JavaScript
import fs from 'node:fs';
|
|
import assert from 'node:assert/strict';
|
|
import { spawn } from 'node:child_process';
|
|
import { createHash } from 'node:crypto';
|
|
import { projectEnvironment } from '../src/core/process-environment.mjs';
|
|
const prefix = '.qa/embedded-browser-c-http-fix';
|
|
const log = prefix + '.tap', stream = fs.createWriteStream(log, { flags: 'wx' });
|
|
const args = ['--test', '--test-reporter=tap', 'tests/workers-http.test.mjs'];
|
|
const child = spawn(process.execPath, args, { windowsHide: true, env: projectEnvironment(), stdio: ['ignore', 'pipe', 'pipe'] });
|
|
child.stdout.pipe(stream, { end: false }); child.stderr.pipe(stream, { end: false });
|
|
const exitCode = await new Promise((resolve, reject) => { child.once('error', reject); child.once('close', resolve); });
|
|
await new Promise(resolve => stream.end(resolve));
|
|
const bytes = fs.readFileSync(log);
|
|
const result = { success: exitCode === 0, exitCode, args, log, logSha256: createHash('sha256').update(bytes).digest('hex'), realModelRequests: 0 };
|
|
fs.writeFileSync(prefix + '-result.json', JSON.stringify(result, null, 2) + '\n', { flag: 'wx' });
|
|
console.log(bytes.toString('utf8')); assert.equal(exitCode, 0);
|