Files
pbakaus_impeccable/tests/lib/engine-bin.mjs
T
Paul Bakaus b6a34de55a Tests: gate behavior on the oracle and the engine binary
Unit tests of the deleted Node scripts and the JS detector are removed;
their behavior is pinned by tests/oracle goldens (frozen JS behavior plus
reviewed deltas) and the engine's own tests. tests/oracle.test.mjs replays
the corpus against the binary (IMPECCABLE_BIN or skill/scripts/bin/<target>/,
via tests/lib/engine-bin.mjs) and skips cleanly without one; the framework
fixture sweep drives live-inject, live-wrap, and detect-csp through the
binary the same way. record.mjs learns --bin. The function-level vectors
under tests/oracle/vectors/calls are committed as the frozen snapshot they
can no longer be regenerated from. Suites: core trimmed to build and
transformer tests, oracle added to the default run, detector/live reduced to
packaging and reference checks, the live-e2e helper tests move to the opt-in
live-e2e lane pending its retarget, cli-remote-e2e is an empty placeholder.

Prepared with AI assistance (Claude Code).
2026-08-31 19:59:20 -07:00

40 lines
1.5 KiB
JavaScript

/**
* Locate the impeccable engine binary for tests that drive verbs end to end.
*
* Order: $IMPECCABLE_BIN, then skill/scripts/bin/<os>-<arch>/impeccable[.exe]
* (what `bun run fetch:engine` writes). Returns null when neither exists so a
* suite can skip cleanly instead of failing on a machine without the engine.
*/
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');
export function engineTarget() {
const platform = { darwin: 'darwin', linux: 'linux', win32: 'windows' }[os.platform()] || 'unknown';
const arch = { arm64: 'arm64', x64: 'x64' }[os.arch()] || 'unknown';
return `${platform}-${arch}`;
}
export function findEngineBinary() {
const fromEnv = process.env.IMPECCABLE_BIN;
if (fromEnv && fs.existsSync(fromEnv)) return path.resolve(fromEnv);
const target = engineTarget();
const local = path.join(REPO_ROOT, 'skill', 'scripts', 'bin', target, target.startsWith('windows-') ? 'impeccable.exe' : 'impeccable');
return fs.existsSync(local) ? local : null;
}
export const ENGINE_MISSING_MESSAGE = 'engine binary not found: run `bun run fetch:engine` or set IMPECCABLE_BIN';
/** Environment the launcher would export for the binary when run from this repo's skill dir. */
export function engineEnv(bin, extra = {}) {
return {
...process.env,
IMPECCABLE_SKILL_DIR: path.join(REPO_ROOT, 'skill'),
IMPECCABLE_SELF: bin,
...extra,
};
}