test: prune redundant and implementation-coupled coverage

This commit is contained in:
morluto committed 2026-11-17 18:48:24 -05:00
1 parent 14b15ba8a5
commit 48e27e19b7
191 files changed
+2757 -5418

No files matched your search

@@ -21,7 +21,6 @@ import {
type ProcessCaptureCleanupHost,
} from "./ProcessCaptureLifecycle.js";
import { parseProcessCapture } from "../../domain/process/processCaptureParsing.js";
import { EMPTY_PROCESS_CAPTURE_EXAMPLE } from "../../domain/process/processCaptureExample.js";
import { projectAnalysisError } from "../../domain/analysisErrorProjection.js";
import {
accountFullyObservedProcessCapture,
@@ -30,14 +29,11 @@ import {
import { analysisErrorProjectionSchema } from "../../domain/analysisErrorProjectionSchema.js";
import {
ProcessCaptureError,
normalizeCaptureFailure,
processCaptureCancelled,
} from "./ProcessCaptureError.js";
import { DarwinProcessOwnershipInspectionError } from "../DarwinProcessRunTokenReader.js";
import {
partialProcessCaptureObservationSchema,
processCaptureSchema,
type ProcessCaptureCleanupReport,
} from "../../domain/process/processCapture.js";
const emptyFilesystemCoverage =
@@ -246,29 +242,6 @@ it("projects complete after-snapshot metadata when a later capture stage fails",
});
});
it("rejects legacy replay output instead of silently discarding it", () => {
expect(
processCaptureSchema.safeParse({
...EMPTY_PROCESS_CAPTURE_EXAMPLE,
protocol_events: [],
}).success,
).toBe(false);
});
it("preserves the actionable Darwin ownership compiler prerequisite", () => {
const normalized = normalizeCaptureFailure(
new DarwinProcessOwnershipInspectionError(
"macOS process ownership inspection requires the Apple Swift compiler via xcrun",
),
);
expect(normalized).toBeInstanceOf(ProcessCaptureError);
expect(normalized).toMatchObject({
message:
"macOS process ownership inspection requires the Apple Swift compiler via xcrun",
});
});
it("settles the capture journal when the application timer is unavailable", async () => {
const applicationTimer = vi
.spyOn(globalThis, "setTimeout")
@@ -803,43 +776,6 @@ it("fails closed on Windows before resolving or launching scenario paths", async
});
});
it("retains the root start identity once at launch and signals only with it", async () => {
const observe = vi.fn(async () => ({
state: "readable" as const,
identity: "id-launch",
}));
const signal = vi.fn(async () => "signaled" as const);
const signalRoot = retainRootSignaller(
4242,
retainRootIdentity(4242, "captured-run", observe),
signal,
);
expect(
observe,
"the identity is read at launch, before any signal",
).toHaveBeenCalledTimes(1);
expect(
await signalRoot.signal("SIGTERM"),
"a matching identity is signalled",
).toEqual({
delivery: "signaled",
});
await signalRoot.signal("SIGKILL");
expect(
observe,
"later signals never re-read the identity",
).toHaveBeenCalledTimes(1);
expect(
signal.mock.calls,
"both signals carry the pid and the identity retained at launch",
).toEqual([
[4242, "id-launch", "SIGTERM"],
[4242, "id-launch", "SIGKILL"],
]);
});
it.each([
["a vanished root", async () => undefined, { delivery: "gone" }],
[
@@ -968,35 +904,6 @@ it.each(["signaled", "gone", "identity-changed", "unverified"] as const)(
},
);
it("seeds a finalization observation only for a scenario with an interval", () => {
const seed = {
frames: [],
interactions: [],
samples: [],
eventJournal: [],
before: {
files: [],
truncated: false,
completeRoots: [],
coverage: emptyFilesystemCoverage,
},
};
expect(
Object.keys(createProcessCaptureObservationBuffer(seed)),
"a default scenario keeps the base observation keys",
).not.toContain("finalization");
expect(
Object.keys(
createProcessCaptureObservationBuffer({
...seed,
finalizationEnabled: true,
}),
),
"a scenario with an interval carries the finalization observation",
).toContain("finalization");
});
it("keeps a non-empty reason when the identity inspection fails without a message", async () => {
const signalRoot = retainRootSignaller(
4242,
+14 -41
View File
@@ -1,40 +1,13 @@
import { expect, it } from "vitest";
import {
classifyLaunchErrno,
describeLaunchFailure,
launcherFailureOf,
} from "./launchFailure.js";
import { describeLaunchFailure, launcherFailureOf } from "./launchFailure.js";
it.each([
["ENOENT", "missing"],
["ENOTDIR", "missing"],
["ELOOP", "missing"],
["ENAMETOOLONG", "missing"],
["EACCES", "not_executable"],
["EPERM", "not_executable"],
["ENOEXEC", "not_executable"],
["EISDIR", "not_executable"],
])("classifies spawn %s as %s", (code, kind) => {
expect(classifyLaunchErrno(code)).toEqual({ kind, code });
});
it.each([["ETIMEDOUT"], ["toString"]])(
"leaves %j an unrecognised launch failure",
(code) => {
expect(classifyLaunchErrno(code)).toEqual({ kind: "failed", code });
},
);
it.each([[1], [null]])("drops a non-string launch code %j", (code) => {
expect(classifyLaunchErrno(code)).toEqual({
kind: "failed",
code: undefined,
});
});
it.each([
["EAGAIN", { kind: "host-exhausted", code: "EAGAIN", resource: "processes" }],
["ELOOP", { kind: "missing", code: "ELOOP" }],
["ENAMETOOLONG", { kind: "missing", code: "ENAMETOOLONG" }],
["ENOEXEC", { kind: "not_executable", code: "ENOEXEC" }],
["EISDIR", { kind: "not_executable", code: "EISDIR" }],
["EPERM", { kind: "not_executable", code: "EPERM" }],
["ENOMEM", { kind: "host-exhausted", code: "ENOMEM", resource: "memory" }],
[
"EMFILE",
@@ -44,16 +17,16 @@ it.each([
"ENFILE",
{ kind: "host-exhausted", code: "ENFILE", resource: "file-descriptors" },
],
["E2BIG", { kind: "argument-list", code: "E2BIG" }],
["ENOENT", { kind: "missing", code: "ENOENT" }],
["EACCES", { kind: "not_executable", code: "EACCES" }],
["ENOEXEC", { kind: "not_executable", code: "ENOEXEC" }],
["EPERM", { kind: "not_executable", code: "EPERM" }],
["EIO", { kind: "failed", code: "EIO" }],
["ETIMEDOUT", { kind: "failed", code: "ETIMEDOUT" }],
[undefined, { kind: "failed", code: undefined }],
[1, { kind: "failed", code: undefined }],
["toString", { kind: "failed", code: "toString" }],
])("classifies launch errno %j once", (code, expected) => {
expect(classifyLaunchErrno(code)).toEqual(expected);
])("classifies %j reported by the OS launcher", (code, expected) => {
expect(
launcherFailureOf(
Object.assign(new Error("failed"), { code, syscall: "spawn" }),
),
).toEqual({ ...expected, executable: undefined, syscall: "spawn" });
});
it.each([
+1 -1
View File
@@ -69,7 +69,7 @@ export type LaunchFailure =
| { readonly kind: "failed"; readonly code: string | undefined };
/** Classify any spawn errno; see `LaunchFailure`. */
export const classifyLaunchErrno = (code: unknown): LaunchFailure => {
const classifyLaunchErrno = (code: unknown): LaunchFailure => {
const refusal = classifyLaunchFailureCode(code);
if (refusal !== undefined) return refusal;
const resource = launchExhaustedResource(code);