30 lines
1.8 KiB
JavaScript
30 lines
1.8 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 { randomUUID } from 'node:crypto';
|
|
import { fixture, launchWorkbench } from '../tests/helpers.mjs';
|
|
|
|
const base = path.resolve('.qa/model-selection-k-ui-regression-' + randomUUID()); fs.mkdirSync(base, { recursive: true }); console.log('EVIDENCE ' + base);
|
|
const results = [];
|
|
for (const script of (process.argv.length > 2 ? process.argv.slice(2) : ['verify-model-center-ui', 'verify-model-protocols-ui', 'verify-model-identity-ui', 'verify-ui', 'verify-diagnostics-ui', 'verify-execution-ui'])) {
|
|
const disposers = [], t = { after: fn => disposers.push(fn) }; let host;
|
|
try {
|
|
if (['verify-ui', 'verify-diagnostics-ui', 'verify-execution-ui'].includes(script)) {
|
|
const f = fixture(t); f.store.close(); host = await launchWorkbench(t, f.data);
|
|
assert.equal(host.bootstrap.config.mode, 'demo'); assert.equal(host.bootstrap.config.hasKey, false);
|
|
}
|
|
const log = path.join(base, script + '.log'), fd = fs.openSync(log, 'wx'); let code;
|
|
try {
|
|
code = await new Promise((resolve, reject) => {
|
|
const child = spawn(process.execPath, ['scripts/' + script + '.mjs'], { windowsHide: true, stdio: ['ignore', fd, fd],
|
|
env: { ...process.env, ...(host ? { AGENT_WORKBENCH_URL: host.url } : {}) } });
|
|
child.once('error', reject); child.once('close', resolve);
|
|
});
|
|
} finally { fs.closeSync(fd); }
|
|
results.push({ script, code, log }); console.log(JSON.stringify({ script, code }));
|
|
assert.equal(code, 0, script);
|
|
} finally { for (const dispose of disposers.reverse()) await dispose(); }
|
|
}
|
|
fs.writeFileSync(path.join(base, 'result.json'), JSON.stringify({ success: true, results, realModelRequests: 0 }, null, 2) + '\n', { flag: 'wx' });
|