mutant-cafe 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/bin.js +94 -24
- package/dist/bin.js.map +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -166,7 +166,9 @@ Selection and partial failures come from Vitest's reporter hooks, not its human-
|
|
|
166
166
|
|
|
167
167
|
### Warm and cold runs
|
|
168
168
|
|
|
169
|
-
The baseline has a 30-minute overall hang guard, including selection and process startup. Set `--baseline-timeout 2400` (seconds), or `baselineTimeoutMs` in `mutants.config.json`, for a longer suite. Expiry reports `BaselineTimedOut`, names the limit and flag, and exits 3 rather than calling the original tests failed. Each paired calibration run uses that same baseline budget independently, across all scratch copies. Each cold execution also includes startup in its existing per-run budget. Cold runs launch the installed project's Vitest bin through
|
|
169
|
+
The baseline has a 30-minute overall hang guard, including selection and process startup. Set `--baseline-timeout 2400` (seconds), or `baselineTimeoutMs` in `mutants.config.json`, for a longer suite. Expiry reports `BaselineTimedOut`, names the limit and flag, and exits 3 rather than calling the original tests failed. Each paired calibration run uses that same baseline budget independently, across all scratch copies. Each cold execution also includes startup in its existing per-run budget. Cold runs launch the installed project's Vitest bin through the current runtime, without an npm wrapper or shell lookup; the printed command names the actual generated launcher. Cleanup runs after deadline expiry before the next execution.
|
|
170
|
+
|
|
171
|
+
Cold, warm and preflight launches inherit only supported resolution flags from the parent runtime arguments: `--conditions` (`-C`), `--import`, `--require` (`-r`), Bun's `--preload`, and Node's `--experimental-loader` (`--loader`) and `--experimental-import-meta-resolve`. Relative preload and loader paths resolve from the original working directory. Debugger, entry, test and watch modes are dropped with a warning; other runtime arguments are not replayed. The installed runner is still Vitest when launched through Bun, not `bun test`.
|
|
170
172
|
|
|
171
173
|
Set `MUTANT_CAFE_PROCESS_TRACE=/absolute/path/trace.jsonl` to opt into timestamped startup and cleanup stages: parent spawn, preload, birth inspection, child spawn, Vitest resolution/start, test-module start and cwd inspection. Traces append process IDs, times and stage details, not arguments, environment contents or test output. No trace file is written by default.
|
|
172
174
|
|
package/dist/bin.js
CHANGED
|
@@ -43,7 +43,10 @@ var ProgramLoadError = class extends Schema2.TaggedError()("ProgramLoadError", {
|
|
|
43
43
|
diagnostics: Schema2.Array(Schema2.String)
|
|
44
44
|
}) {
|
|
45
45
|
};
|
|
46
|
-
var formatTestCommand = (command) =>
|
|
46
|
+
var formatTestCommand = (command) => {
|
|
47
|
+
const launcher = command.findIndex((arg) => !arg.startsWith("-") && /[\\/]mutant-vitest-[^\\/]+[\\/]launch\.mjs$/.test(arg));
|
|
48
|
+
return launcher > 0 ? `vitest ${command.slice(launcher + 1).filter((arg) => arg === "--reporter=default" || !arg.startsWith("--reporter=")).join(" ")} (via ${command.join(" ")})` : command.join(" ");
|
|
49
|
+
};
|
|
47
50
|
var BaselineFailed = class extends Schema2.TaggedError()("BaselineFailed", {
|
|
48
51
|
exitCode: Schema2.Int,
|
|
49
52
|
command: Schema2.Array(Schema2.String),
|
|
@@ -1759,6 +1762,49 @@ const traceProcess = (stage, details = {}) => {
|
|
|
1759
1762
|
};
|
|
1760
1763
|
`;
|
|
1761
1764
|
|
|
1765
|
+
// packages/runner/src/RuntimeArgs.ts
|
|
1766
|
+
import { isAbsolute, resolve as resolve2 } from "node:path";
|
|
1767
|
+
import { pathToFileURL } from "node:url";
|
|
1768
|
+
var isPath = (value) => isAbsolute(value) || /^\.{1,2}([/\\]|$)/.test(value);
|
|
1769
|
+
function runtimeArgs(argv, cwd, bun) {
|
|
1770
|
+
const args = [];
|
|
1771
|
+
const dropped = [];
|
|
1772
|
+
for (let index = 0; index < argv.length; index++) {
|
|
1773
|
+
const raw = argv[index];
|
|
1774
|
+
const attached = /^(-[Crep])(?:=)?(.+)$/.exec(raw);
|
|
1775
|
+
const equals = raw.indexOf("=");
|
|
1776
|
+
const key = attached?.[1] ?? (equals < 0 ? raw : raw.slice(0, equals));
|
|
1777
|
+
const inline = attached?.[2] ?? (equals < 0 ? void 0 : raw.slice(equals + 1));
|
|
1778
|
+
if (["-e", "--eval", "-p", "--print", "-i", "--interactive", "-c", "--check"].includes(key)) {
|
|
1779
|
+
dropped.push(key);
|
|
1780
|
+
break;
|
|
1781
|
+
}
|
|
1782
|
+
if (/^--(?:inspect|test|watch)(?:-|$)/.test(key)) {
|
|
1783
|
+
dropped.push(key);
|
|
1784
|
+
continue;
|
|
1785
|
+
}
|
|
1786
|
+
const condition = key === "--conditions" || key === "-C";
|
|
1787
|
+
const preload = key === "--require" || key === "-r" || key === "--import" || bun && key === "--preload";
|
|
1788
|
+
const loader = !bun && (key === "--loader" || key === "--experimental-loader");
|
|
1789
|
+
if (!bun && key === "--experimental-import-meta-resolve") {
|
|
1790
|
+
if (inline === void 0) args.push(key);
|
|
1791
|
+
continue;
|
|
1792
|
+
}
|
|
1793
|
+
if (!condition && !preload && !loader) continue;
|
|
1794
|
+
const value = inline ?? argv[index + 1];
|
|
1795
|
+
if (!value || inline === void 0 && value.startsWith("-")) continue;
|
|
1796
|
+
if (inline === void 0) index++;
|
|
1797
|
+
if (condition) {
|
|
1798
|
+
args.push(`--conditions=${value}`);
|
|
1799
|
+
continue;
|
|
1800
|
+
}
|
|
1801
|
+
const option = bun ? "--preload" : loader ? "--experimental-loader" : key === "--import" ? key : "--require";
|
|
1802
|
+
const location = !isPath(value) ? value : option === "--import" || loader ? pathToFileURL(resolve2(cwd, value)).href : resolve2(cwd, value);
|
|
1803
|
+
args.push(`${option}=${location}`);
|
|
1804
|
+
}
|
|
1805
|
+
return { args, dropped };
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1762
1808
|
// packages/runner/src/ProcessTree.ts
|
|
1763
1809
|
import * as Console2 from "effect/Console";
|
|
1764
1810
|
import * as Clock from "effect/Clock";
|
|
@@ -1771,9 +1817,10 @@ import * as Semaphore from "effect/Semaphore";
|
|
|
1771
1817
|
import { execFile } from "node:child_process";
|
|
1772
1818
|
import { promisify } from "node:util";
|
|
1773
1819
|
import { randomUUID } from "node:crypto";
|
|
1774
|
-
import { pathToFileURL } from "node:url";
|
|
1820
|
+
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
1775
1821
|
var execute = promisify(execFile);
|
|
1776
1822
|
var liveLedgers = /* @__PURE__ */ new Set();
|
|
1823
|
+
var warnedRuntimeFlags = /* @__PURE__ */ new Set();
|
|
1777
1824
|
var ProcessInspector = Context2.Reference("mutant.cafe/ProcessInspector", { defaultValue: () => ({ inspect: (args) => Effect4.tryPromise({
|
|
1778
1825
|
try: (signal) => execute("/bin/ps", [...args], { signal, encoding: "utf8", maxBuffer: 32 * 1024 * 1024, timeout: 2e3, env: { PATH: process.env.PATH, LC_ALL: "C", TZ: "UTC" } }),
|
|
1779
1826
|
catch: () => new TestSpawnError({ command: ["ps"], message: "Cannot inspect owned test processes" })
|
|
@@ -1851,7 +1898,7 @@ const environment = node => {
|
|
|
1851
1898
|
const env = { ...process.env };
|
|
1852
1899
|
const ownImport = "--import=" + preload;
|
|
1853
1900
|
const original = (env.NODE_OPTIONS || "").replaceAll(ownImport, "").trim();
|
|
1854
|
-
if (node && env.${ledgerKey} === ledger && env.${tokenKey} === token) env.NODE_OPTIONS = (original + " " + ownImport).trim();
|
|
1901
|
+
if ((node || process.versions.bun !== undefined) && env.${ledgerKey} === ledger && env.${tokenKey} === token) env.NODE_OPTIONS = (original + " " + ownImport).trim();
|
|
1855
1902
|
else if (original) env.NODE_OPTIONS = original;
|
|
1856
1903
|
else delete env.NODE_OPTIONS;
|
|
1857
1904
|
return env;
|
|
@@ -1899,13 +1946,22 @@ syncBuiltinESMExports();
|
|
|
1899
1946
|
var Record2 = Schema6.Struct({ pid: Schema6.Int, birth: Schema6.String });
|
|
1900
1947
|
var acquireProcessTree = Effect4.fn("ProcessTree.acquire")(function* (scratch, onBackstop, processesSince) {
|
|
1901
1948
|
const fs = yield* FileSystem3.FileSystem;
|
|
1902
|
-
const
|
|
1949
|
+
const bun = process.versions.bun !== void 0;
|
|
1950
|
+
const inherited = runtimeArgs(process.execArgv, process.cwd(), bun);
|
|
1951
|
+
const launchArgs = (script2) => [...bun ? ["--preload", script2] : [], ...inherited.args];
|
|
1952
|
+
const acquisitionError = (script2) => (error3) => new TestSpawnError({
|
|
1953
|
+
command: [process.execPath, ...launchArgs(script2)],
|
|
1954
|
+
message: `Cannot prepare process ownership: ${error3.message}`
|
|
1955
|
+
});
|
|
1956
|
+
const directory = yield* fs.makeTempDirectory({ prefix: "mutant-processes-" }).pipe(
|
|
1957
|
+
Effect4.mapError(acquisitionError("<unallocated ownership preload>"))
|
|
1958
|
+
);
|
|
1903
1959
|
const ledger = `${directory}/pids.jsonl`;
|
|
1904
1960
|
const script = `${directory}/register.mjs`;
|
|
1905
1961
|
const token = yield* Effect4.sync(randomUUID);
|
|
1906
|
-
const url =
|
|
1907
|
-
yield* fs.writeFileString(ledger, "");
|
|
1908
|
-
yield* fs.writeFileString(script, preloadSource);
|
|
1962
|
+
const url = pathToFileURL2(script).href;
|
|
1963
|
+
yield* fs.writeFileString(ledger, "").pipe(Effect4.mapError(acquisitionError(script)));
|
|
1964
|
+
yield* fs.writeFileString(script, preloadSource).pipe(Effect4.mapError(acquisitionError(script)));
|
|
1909
1965
|
liveLedgers.add(ledger);
|
|
1910
1966
|
const trace = (stage, details = {}) => {
|
|
1911
1967
|
const destination = process.env.MUTANT_CAFE_PROCESS_TRACE;
|
|
@@ -2143,8 +2199,22 @@ var acquireProcessTree = Effect4.fn("ProcessTree.acquire")(function* (scratch, o
|
|
|
2143
2199
|
liveLedgers.delete(ledger);
|
|
2144
2200
|
}))));
|
|
2145
2201
|
const existing = process.env.NODE_OPTIONS ?? "";
|
|
2202
|
+
const dropped = [...new Set(inherited.dropped)].filter((flag) => !warnedRuntimeFlags.has(flag));
|
|
2203
|
+
if (dropped.length) {
|
|
2204
|
+
for (const flag of dropped) warnedRuntimeFlags.add(flag);
|
|
2205
|
+
yield* Console2.warn(`Warning: not forwarding runtime flags to Vitest children: ${dropped.join(", ")}`);
|
|
2206
|
+
}
|
|
2146
2207
|
return {
|
|
2147
|
-
env: {
|
|
2208
|
+
env: {
|
|
2209
|
+
...process.env,
|
|
2210
|
+
MUTANT_CAFE_PROCESS_PHASE: void 0,
|
|
2211
|
+
[tokenKey]: token,
|
|
2212
|
+
[ledgerKey]: ledger,
|
|
2213
|
+
[preloadKey]: url,
|
|
2214
|
+
NODE_OPTIONS: `${existing} --import=${url}`.trim(),
|
|
2215
|
+
...bun ? { BUN_OPTIONS: `${process.env.BUN_OPTIONS ?? ""} --preload=${url}`.trim() } : {}
|
|
2216
|
+
},
|
|
2217
|
+
launchArgs: launchArgs(script),
|
|
2148
2218
|
addRoot: (pid) => {
|
|
2149
2219
|
roots.add(pid);
|
|
2150
2220
|
},
|
|
@@ -2310,7 +2380,7 @@ var preflight = Effect5.fn("TestRunner.preflight")(function* (root, tsconfig = "
|
|
|
2310
2380
|
const since = options.processesSince ?? (yield* Clock2.currentTimeMillis);
|
|
2311
2381
|
const owned = yield* acquireProcessTree(root, options.onBackstop, since);
|
|
2312
2382
|
yield* owned.trace("preflight-start", { budgetMs: timeoutMs });
|
|
2313
|
-
const output = yield* spawner.string(ChildProcess2.make(process.execPath, ["--input-type=module", "--eval", probe, tsconfig], { cwd: root, env: owned.env, detached: true, killSignal: "SIGKILL", forceKillAfter: "100 millis", stdin: "ignore" })).pipe(Effect5.onInterrupt(() => owned.cleanup));
|
|
2383
|
+
const output = yield* spawner.string(ChildProcess2.make(process.execPath, [...owned.launchArgs, "--input-type=module", "--eval", probe, tsconfig], { cwd: root, env: owned.env, detached: true, killSignal: "SIGKILL", forceKillAfter: "100 millis", stdin: "ignore" })).pipe(Effect5.onInterrupt(() => owned.cleanup));
|
|
2314
2384
|
yield* owned.trace("preflight-done");
|
|
2315
2385
|
const version = output.split("\n").find((line) => line.startsWith("mutant-cafe-vitest-version:"))?.slice("mutant-cafe-vitest-version:".length);
|
|
2316
2386
|
if (version !== void 0) {
|
|
@@ -2345,7 +2415,7 @@ import * as Stream3 from "effect/Stream";
|
|
|
2345
2415
|
import * as Schema9 from "effect/Schema";
|
|
2346
2416
|
import * as Scope3 from "effect/Scope";
|
|
2347
2417
|
import { createRequire } from "node:module";
|
|
2348
|
-
import { pathToFileURL as
|
|
2418
|
+
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
2349
2419
|
import * as ChildProcess3 from "effect/process/ChildProcess";
|
|
2350
2420
|
import * as ChildProcessSpawner5 from "effect/process/ChildProcessSpawner";
|
|
2351
2421
|
|
|
@@ -2733,7 +2803,7 @@ var Host = class {
|
|
|
2733
2803
|
constructor(root, script, reporter, tree, scope, selectionOnly = false, decode = decodeWarmMessage) {
|
|
2734
2804
|
this.tree = tree;
|
|
2735
2805
|
this.scope = scope;
|
|
2736
|
-
this.child = spawn(process.execPath, [script, reporter, selectionOnly ? "select" : "run"], {
|
|
2806
|
+
this.child = spawn(process.execPath, [...tree.launchArgs, script, reporter, selectionOnly ? "select" : "run"], {
|
|
2737
2807
|
cwd: root,
|
|
2738
2808
|
env: tree.env,
|
|
2739
2809
|
detached: true,
|
|
@@ -2782,10 +2852,10 @@ var Host = class {
|
|
|
2782
2852
|
this.pending?.reject(error3 instanceof ReporterMessageError ? error3 : new ReporterMessageError(String(error3)));
|
|
2783
2853
|
}
|
|
2784
2854
|
});
|
|
2785
|
-
this.exited = new Promise((
|
|
2855
|
+
this.exited = new Promise((resolve3) => this.child.once("close", () => {
|
|
2786
2856
|
this.pending?.reject(new Error(`Vitest host exited: ${this.output.slice(-4e3)}`));
|
|
2787
2857
|
this.pending = void 0;
|
|
2788
|
-
|
|
2858
|
+
resolve3();
|
|
2789
2859
|
}));
|
|
2790
2860
|
this.child.on("error", (error3) => {
|
|
2791
2861
|
this.pending?.reject(error3);
|
|
@@ -2793,16 +2863,16 @@ var Host = class {
|
|
|
2793
2863
|
});
|
|
2794
2864
|
}
|
|
2795
2865
|
wait() {
|
|
2796
|
-
return new Promise((
|
|
2797
|
-
this.pending = { resolve:
|
|
2866
|
+
return new Promise((resolve3, reject) => {
|
|
2867
|
+
this.pending = { resolve: resolve3, reject };
|
|
2798
2868
|
});
|
|
2799
2869
|
}
|
|
2800
2870
|
quiesce() {
|
|
2801
|
-
const started = new Promise((
|
|
2802
|
-
this.quiescing =
|
|
2871
|
+
const started = new Promise((resolve3) => {
|
|
2872
|
+
this.quiescing = resolve3;
|
|
2803
2873
|
});
|
|
2804
|
-
const done = new Promise((
|
|
2805
|
-
this.quiesced =
|
|
2874
|
+
const done = new Promise((resolve3) => {
|
|
2875
|
+
this.quiesced = resolve3;
|
|
2806
2876
|
});
|
|
2807
2877
|
this.post({ type: "quiesce" });
|
|
2808
2878
|
return { started, done };
|
|
@@ -3099,8 +3169,7 @@ var TestRunnerLive = Layer3.effect(TestRunner, Effect7.gen(function* () {
|
|
|
3099
3169
|
yield* fs.writeFileString(launcher, vitestLauncherSource).pipe(Effect7.mapError((error3) => new TestSpawnError({ command: ["vitest"], message: String(error3) })));
|
|
3100
3170
|
const marker = `mutant-cafe:${path.basename(reporterDir)}:`;
|
|
3101
3171
|
yield* fs.writeFileString(reporter, reporterSource(marker, probe2)).pipe(Effect7.mapError((error3) => new TestSpawnError({ command: ["vitest"], message: String(error3) })));
|
|
3102
|
-
const
|
|
3103
|
-
process.execPath,
|
|
3172
|
+
const vitestArgs = [
|
|
3104
3173
|
launcher,
|
|
3105
3174
|
...args,
|
|
3106
3175
|
"--reporter=default",
|
|
@@ -3114,8 +3183,9 @@ var TestRunnerLive = Layer3.effect(TestRunner, Effect7.gen(function* () {
|
|
|
3114
3183
|
const started = yield* Clock4.currentTimeMillis;
|
|
3115
3184
|
const owned = yield* acquireProcessTree(dir.path, onBackstop(dir.path), openedAt.get(dir.path)).pipe(
|
|
3116
3185
|
Effect7.provideService(FileSystem7.FileSystem, fs),
|
|
3117
|
-
Effect7.mapError((error3) => new TestSpawnError({ command, message:
|
|
3186
|
+
Effect7.mapError((error3) => new TestSpawnError({ command: [...error3.command, ...vitestArgs], message: error3.message }))
|
|
3118
3187
|
);
|
|
3188
|
+
const command = [process.execPath, ...owned.launchArgs, ...vitestArgs];
|
|
3119
3189
|
const chunks = [];
|
|
3120
3190
|
let exitCode = 1;
|
|
3121
3191
|
const child = Effect7.scoped(Effect7.gen(function* () {
|
|
@@ -3276,7 +3346,7 @@ Vitest timed out after ${overallMs}ms overall, including startup.
|
|
|
3276
3346
|
const token = `mutant-cafe-probe:${path.basename(temporary)}`;
|
|
3277
3347
|
const setupFile = path.join(temporary, "setup.mjs");
|
|
3278
3348
|
const vitest = yield* Effect7.try({
|
|
3279
|
-
try: () =>
|
|
3349
|
+
try: () => pathToFileURL3(path.join(path.dirname(createRequire(path.join(dir.path, "package.json")).resolve("vitest/package.json")), "dist/index.js")).href,
|
|
3280
3350
|
catch: (error3) => new TestSpawnError({ command: ["vitest", "probe"], message: String(error3) })
|
|
3281
3351
|
});
|
|
3282
3352
|
yield* fs.writeFileString(setupFile, `import { beforeAll, afterAll } from ${JSON.stringify(vitest)};
|
|
@@ -4357,7 +4427,7 @@ ${error3.output.slice(-8e3)}`
|
|
|
4357
4427
|
var runCli = Effect12.fn("runCli")(function* (options) {
|
|
4358
4428
|
const code = yield* Ref.make(0);
|
|
4359
4429
|
const command = makeCommand({ ...options, onExit: (value) => Ref.set(code, value) });
|
|
4360
|
-
yield* Command.runWith(command, { version: "0.1.
|
|
4430
|
+
yield* Command.runWith(command, { version: "0.1.8" })(options.args).pipe(
|
|
4361
4431
|
Effect12.catch((error3) => Effect12.gen(function* () {
|
|
4362
4432
|
yield* Console7.error(error3._tag === "ProgramLoadError" ? `${error3.tsconfig}:
|
|
4363
4433
|
${error3.diagnostics.join("\n")}` : error3._tag === "TestSpawnError" && error3.kind === "vitest-version" ? error3.message : error3._tag === "BaselineTimedOut" ? error3.message : error3._tag === "BaselineFailed" ? `Baseline failed (${error3.exitCode}): ${formatTestCommand(error3.command)}
|