Adds a local runner that calls a maigret binary on PATH with --folderoutput, selected by MAIGRET_RUNNER=docker|local|auto (auto: local if installed, else Docker). The Docker image now bundles maigret 0.6.6 with the pdf extra and sets MAIGRET_RUNNER=local, so it runs on hosted platforms with no Docker daemon and PDF reports work. Runner selection is in src/runner.ts with unit tests; CI runs them. Input validation and execFile argument arrays are unchanged. Closes #22 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
1.3 KiB
JavaScript
32 lines
1.3 KiB
JavaScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { buildCommand, parseRunnerSetting, resolveRunner, DOCKER_IMAGE } from '../build/runner.js';
|
|
|
|
test('MAIGRET_RUNNER parsing', () => {
|
|
assert.equal(parseRunnerSetting(undefined), 'auto');
|
|
assert.equal(parseRunnerSetting(''), 'auto');
|
|
assert.equal(parseRunnerSetting(' Local '), 'local');
|
|
assert.equal(parseRunnerSetting('docker'), 'docker');
|
|
assert.throws(() => parseRunnerSetting('podman'), /MAIGRET_RUNNER/);
|
|
});
|
|
|
|
test('auto prefers a local maigret, falls back to Docker', () => {
|
|
assert.equal(resolveRunner('auto', true), 'local');
|
|
assert.equal(resolveRunner('auto', false), 'docker');
|
|
assert.equal(resolveRunner('docker', true), 'docker');
|
|
assert.equal(resolveRunner('local', false), 'local');
|
|
});
|
|
|
|
test('docker command mounts the reports dir and keeps arguments as an array', () => {
|
|
const c = buildCommand('docker', '/r', ['alice', '--txt']);
|
|
assert.deepEqual(c, {
|
|
cmd: 'docker',
|
|
args: ['run', '--rm', '-v', '/r:/app/reports', DOCKER_IMAGE, 'alice', '--txt'],
|
|
});
|
|
});
|
|
|
|
test('local command writes reports to the reports dir', () => {
|
|
const c = buildCommand('local', '/r', ['alice', '--txt']);
|
|
assert.deepEqual(c, { cmd: 'maigret', args: ['alice', '--txt', '--folderoutput', '/r'] });
|
|
});
|