25 lines
1.0 KiB
JavaScript
25 lines
1.0 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { executeAndReport } from '../../scripts/run-profile.mjs';
|
|
|
|
test('builds the report after both passing and failing runs, preserving runner status', async () => {
|
|
for (const code of [0, 1, 7]) {
|
|
const events = [];
|
|
const result = await executeAndReport(async () => { events.push('runner'); return code; }, async () => { events.push('report'); });
|
|
assert.equal(result, code);
|
|
assert.deepEqual(events, ['runner', 'report']);
|
|
}
|
|
});
|
|
|
|
test('attempts reporting after runner startup failure', async () => {
|
|
let reported = false;
|
|
assert.equal(await executeAndReport(async () => { throw new Error('spawn failed'); }, () => { reported = true; }), 1);
|
|
assert.ok(reported);
|
|
});
|
|
|
|
test('a report failure cannot convert a failed runner to success or hide its exit code', async () => {
|
|
for (const code of [0, 7]) {
|
|
assert.equal(await executeAndReport(async () => code, () => { throw new Error('unwritable report'); }), code || 1);
|
|
}
|
|
});
|