29 lines
1.5 KiB
JavaScript
29 lines
1.5 KiB
JavaScript
// Run only under Sage's CLEAR, with scratch TMPDIR and MOSAIC_REQUIRE_EDITOR_BUILD=1.
|
|
// Mutants alter only the fixture-served copy of chat.js; repository source is untouched.
|
|
import { spawnSync } from 'node:child_process';
|
|
import { writeFileSync } from 'node:fs';
|
|
import { join } from 'node:path';
|
|
const file = 'packages/webui/tests/thread-sharing.test.mjs';
|
|
const results = [];
|
|
for (const mutant of ['composer', 'open', 'share', 'create']) {
|
|
for (const [stage, pattern, expected] of [
|
|
['kill', '193d viewer UI has no', 1],
|
|
['bypass', '193d bypassed UI checks', 0],
|
|
]) {
|
|
const run = spawnSync(process.execPath, ['--test', '--test-concurrency=1', '--test-name-pattern=' + pattern, file], {
|
|
env: { ...process.env, POE_UI_MUTANT: mutant }, encoding: 'utf8', timeout: 90000,
|
|
});
|
|
const log = join(process.env.TMPDIR, `poe-208-${mutant}-${stage}.tap`);
|
|
writeFileSync(log, (run.stdout ?? '') + (run.stderr ?? ''));
|
|
const killedByAssertion = /ERR_ASSERTION/.test(run.stdout ?? '');
|
|
const passed = run.status === expected && (stage !== 'kill' || killedByAssertion);
|
|
results.push({ mutant, stage, exit: run.status, signal: run.signal, passed, log });
|
|
console.log(JSON.stringify(results.at(-1)));
|
|
if (!passed) {
|
|
writeFileSync(join(process.env.TMPDIR, 'poe-208-mutants.json'), JSON.stringify(results, null, 2));
|
|
process.exit(1);
|
|
}
|
|
}
|
|
}
|
|
writeFileSync(join(process.env.TMPDIR, 'poe-208-mutants.json'), JSON.stringify(results, null, 2));
|