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

-18
View File
@@ -71,21 +71,3 @@ export const selectCliAnalysisSelector = (
);
return ok(selected);
};
/** Preserve a CLI selector supplied positionally or through its named option. */
export const resolveCliAnalysisSelector = (
positional: string | undefined,
named: string | undefined,
option: string,
operation: string,
kind: CliSelectorKind = "text",
): string => {
const selected = selectCliAnalysisSelector(positional, named, {
option,
operation,
kind,
required: true,
});
if (!selected.ok) throw selected.error;
return selected.value!;
};
+1 -1
View File
@@ -27,7 +27,7 @@ const isRegistrationId = (id: string): id is CliCommandRegistrationId =>
* CLI builtins, unknown names ("did you mean"), and a missing or unusable
* recording all describe or search every command.
*/
export const selectCliRegistrations = (
const selectCliRegistrations = (
global: CliGlobalArguments | undefined,
recorded: Readonly<Record<string, string>> | undefined,
): readonly CliCommandRegistrationId[] | undefined => {
+1 -1
View File
@@ -398,7 +398,7 @@ const markdownHeading = (path: readonly string[]): string =>
const markdownEdgeWhitespace = /[\t \p{Z}\ufeff]/u;
/** Encode edge spacing that Markdown can represent as character references. */
export const encodeMarkdownTableCell = (value: string): string => {
const encodeMarkdownTableCell = (value: string): string => {
const escaped = escapeTableCell(value);
let start = 0;
let end = escaped.length;
+18 -29
View File
@@ -1,37 +1,26 @@
/** Closers of process-owned CLI resources, by owner name. */
export class CliResourceOwners {
readonly #closers = new Map<string, () => Promise<void>>();
/** Register an owner's closer; a repeated name keeps its first closer. */
own(name: string, close: () => Promise<void>): void {
if (!this.#closers.has(name)) this.#closers.set(name, close);
}
/** Settle every owner, then report each failure. */
async close(): Promise<void> {
const results = await Promise.allSettled(
[...this.#closers.values()].map((close) => close()),
);
const failures = results.flatMap((result) =>
result.status === "rejected" ? [result.reason] : [],
);
if (failures.length === 1) throw failures[0];
if (failures.length > 1)
throw new AggregateError(failures, "CLI resource cleanup failed");
}
}
/**
* Process-owned CLI resources. Each owning module registers its closer when it
* loads, so a CLI that loads only some command families closes exactly the
* owners it loaded without importing the others.
* loads, so a CLI closes only the command families it loaded.
*/
const processOwners = new CliResourceOwners();
const closers = new Map<string, () => Promise<void>>();
/** Register an owner's closer. A repeated name keeps its first closer. */
export const ownCliProcessResource = (
name: string,
close: () => Promise<void>,
): void => processOwners.own(name, close);
): void => {
if (!closers.has(name)) closers.set(name, close);
};
/** Close every process-owned resource used by CLI commands. */
export const closeCliResources = (): Promise<void> => processOwners.close();
/** Settle every process-owned resource, then report each failure. */
export const closeCliResources = async (): Promise<void> => {
const results = await Promise.allSettled(
[...closers.values()].map((close) => close()),
);
const failures = results.flatMap((result) =>
result.status === "rejected" ? [result.reason] : [],
);
if (failures.length === 1) throw failures[0];
if (failures.length > 1)
throw new AggregateError(failures, "CLI resource cleanup failed");
};
-26
View File
@@ -33,7 +33,6 @@ import {
describeContractDocumentCommand,
type CliDocumentProjection,
type DocumentContract,
type ContractCliDocumentDescription,
type CliContractProjection,
describeOperationChoices,
type CliEvidenceDeliveryChoice,
@@ -59,7 +58,6 @@ import {
projectCliInputFields,
} from "./projectCliAnalysisResult.js";
import {
cliCommands,
contractDescriptionOperations,
distinctOperations,
registerCliCommand,
@@ -556,14 +554,6 @@ const commandPositionals = (
...description.cliPositionals,
];
/** Commands registered on this CLI through `registerContractCommand`. */
export const contractCommandDescriptions = (
cli: CliInstance,
): readonly ContractCliDescription[] =>
cliCommands(cli).flatMap(({ source }) =>
source.kind === "contract" ? [source.description] : [],
);
const commandOptions = (description: ContractCliDescription): z.ZodType => {
const object = z.object(
Object.fromEntries([
@@ -872,14 +862,6 @@ const commandShape = (description: ContractCliDescription) => ({
const schemaSignature = (schema: z.ZodType): string =>
JSON.stringify(z.toJSONSchema(schema, { unrepresentable: "any" }));
/** Route descriptions of commands registered through `registerRoutedCommand`. */
export const routedCommandDescriptions = (
cli: CliInstance,
): readonly ContractCliDescription[] =>
cliCommands(cli).flatMap(({ source }) =>
source.kind === "routed" ? source.descriptions : [],
);
/**
* Register one CLI command whose input chooses the contract input it runs,
* such as `analyze` running static JavaScript analysis on an application
@@ -1116,14 +1098,6 @@ export interface ContractDocumentContext<
readonly opening: Readonly<Record<string, unknown>>;
}
/** Commands registered on this CLI through `registerContractDocumentCommand`. */
export const contractDocumentCommandDescriptions = (
cli: CliInstance,
): readonly ContractCliDocumentDescription[] =>
cliCommands(cli).flatMap(({ source }) =>
source.kind === "document" ? [source.description] : [],
);
/**
* A document field the projection omits or takes as an option is refused
* with its reason rather than passed to an owner that would act on it.
-11
View File
@@ -1,11 +0,0 @@
import { z } from "zod";
/** Repeatable option whose literals the command and its CLI diagnostics exclude. */
export const explicitSensitiveValueOptions = {
sensitiveValue: z
.array(z.string().min(1))
.default([])
.describe(
"Literal string values explicitly marked sensitive; repeat as needed",
),
};