mirror of
https://github.com/morluto/rea.git
synced 2026-11-20 13:45:30 +00:00
* fix(desktop): preserve exact dpkg ownership from partial queries * test(desktop): cover dpkg executable ownership transcripts * test(desktop): keep executable ownership regression outside describe
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { expect, it } from "vitest";
|
|
|
|
import { ArtifactReaderFailure } from "../resources/ArtifactReader.js";
|
|
import { runHostQuery } from "./HostQuery.js";
|
|
|
|
it("returns an inert Node query's actual output and status", async () => {
|
|
expect(
|
|
await runHostQuery(
|
|
process.execPath,
|
|
["-e", "process.stdout.write('query result')"],
|
|
undefined,
|
|
),
|
|
).toEqual({ stdout: "query result", exitCode: 0 });
|
|
});
|
|
|
|
it("retains raw stdout on a completed nonzero exit when requested", async () => {
|
|
const output = await runHostQuery(
|
|
process.execPath,
|
|
[
|
|
"-e",
|
|
"process.stdout.write(Buffer.from([0x61, 0xff])); process.exitCode = 1;",
|
|
],
|
|
undefined,
|
|
{ preserveStdoutBytes: true },
|
|
);
|
|
expect(output).toEqual({
|
|
stdout: "a�",
|
|
stdoutBuffer: Buffer.from([0x61, 0xff]),
|
|
exitCode: 1,
|
|
});
|
|
});
|
|
|
|
it("preserves cancellation recorded by the actual command owner", async () => {
|
|
const reason = new Error("caller cancelled host query");
|
|
const failure = await runHostQuery(
|
|
process.execPath,
|
|
["-e", "void 0"],
|
|
AbortSignal.abort(reason),
|
|
).catch((cause: unknown) => cause);
|
|
expect(failure).toBeInstanceOf(ArtifactReaderFailure);
|
|
expect(failure).toMatchObject({ reason: "cancelled", cause: reason });
|
|
if (!(failure instanceof ArtifactReaderFailure))
|
|
throw new Error("expected owner cancellation");
|
|
expect(failure.cause).toBe(reason);
|
|
});
|