fix(native): classify pre-aborted analysis first
This commit is contained in:
@@ -129,6 +129,8 @@ class NativeMacOSClient implements AnalysisClient {
|
|||||||
parameters: Readonly<Record<string, JsonValue>>,
|
parameters: Readonly<Record<string, JsonValue>>,
|
||||||
options?: { readonly signal?: AbortSignal },
|
options?: { readonly signal?: AbortSignal },
|
||||||
) {
|
) {
|
||||||
|
if (options?.signal?.aborted === true)
|
||||||
|
return err(new AnalysisCancelledError(operation));
|
||||||
if (operation === "health")
|
if (operation === "health")
|
||||||
return ok(createAnalysisExecution(null, IDENTITY));
|
return ok(createAnalysisExecution(null, IDENTITY));
|
||||||
if (!isNativeOperation(operation))
|
if (!isNativeOperation(operation))
|
||||||
|
|||||||
@@ -137,6 +137,26 @@ describe("native macOS provider", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("classifies pre-aborted requests before operation or runner discovery", async () => {
|
||||||
|
const controller = new AbortController();
|
||||||
|
controller.abort();
|
||||||
|
const runner = new CountingRunner();
|
||||||
|
const client = new NativeMacOSProvider(runner, "linux").createClient(
|
||||||
|
machoTarget("/fixture"),
|
||||||
|
);
|
||||||
|
|
||||||
|
const result = await client.execute(
|
||||||
|
"list_architectures",
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
signal: controller.signal,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(!result.ok && result.error._tag).toBe("AnalysisCancelledError");
|
||||||
|
expect(runner.calls).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
it("parses thin and universal lipo fixtures", async () => {
|
it("parses thin and universal lipo fixtures", async () => {
|
||||||
expect(
|
expect(
|
||||||
parseLipoArchitectures(await fixture("lipo-thin.txt")),
|
parseLipoArchitectures(await fixture("lipo-thin.txt")),
|
||||||
@@ -169,6 +189,15 @@ class FailingRunner implements NativeCommandRunner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CountingRunner implements NativeCommandRunner {
|
||||||
|
calls = 0;
|
||||||
|
|
||||||
|
run(tool: string) {
|
||||||
|
this.calls += 1;
|
||||||
|
return Promise.resolve(err(new NativeCommandFailure(tool, "unavailable")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const outputFor = async (
|
const outputFor = async (
|
||||||
tool: string,
|
tool: string,
|
||||||
arguments_: readonly string[],
|
arguments_: readonly string[],
|
||||||
|
|||||||
Reference in New Issue
Block a user