fix(native): classify pre-aborted analysis first
This commit is contained in:
parent
4c54ff6bca
commit
dfd598f765
|
|
@ -129,6 +129,8 @@ class NativeMacOSClient implements AnalysisClient {
|
|||
parameters: Readonly<Record<string, JsonValue>>,
|
||||
options?: { readonly signal?: AbortSignal },
|
||||
) {
|
||||
if (options?.signal?.aborted === true)
|
||||
return err(new AnalysisCancelledError(operation));
|
||||
if (operation === "health")
|
||||
return ok(createAnalysisExecution(null, IDENTITY));
|
||||
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 () => {
|
||||
expect(
|
||||
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 (
|
||||
tool: string,
|
||||
arguments_: readonly string[],
|
||||
|
|
|
|||
Loading…
Reference in New Issue