


























@@ -56,6 +56,10 @@ function runWritePlan(args: string[], input?: string, env?: NodeJS.ProcessEnv) {
5656});
5757}
585859+async function expectPathMissing(targetPath: string): Promise<void> {
60+await expect(fs.access(targetPath)).rejects.toMatchObject({ code: "ENOENT" });
61+}
62+5963const hasAbsolutePythonCandidate = SANDBOX_PINNED_MUTATION_PYTHON_CANDIDATES.some((candidate) =>
6064existsSync(candidate),
6165);
@@ -227,7 +231,7 @@ describe("sandbox pinned mutation helper", () => {
227231const result = runMutation(["write", workspace, "alias", "escape.txt", "0"], "owned");
228232229233expect(result.status).not.toBe(0);
230-await expect(fs.readFile(path.join(outside, "escape.txt"), "utf8")).rejects.toThrow();
234+await expectPathMissing(path.join(outside, "escape.txt"));
231235});
232236},
233237);
@@ -243,7 +247,7 @@ describe("sandbox pinned mutation helper", () => {
243247const result = runMutation(["mkdirp", workspace, "alias/nested"]);
244248245249expect(result.status).not.toBe(0);
246-await expect(fs.readFile(path.join(outside, "nested"), "utf8")).rejects.toThrow();
250+await expectPathMissing(path.join(outside, "nested"));
247251});
248252});
249253@@ -259,7 +263,7 @@ describe("sandbox pinned mutation helper", () => {
259263const result = runMutation(["remove", workspace, "", "link.txt", "0", "0"]);
260264261265expect(result.status).toBe(0);
262-await expect(fs.readlink(path.join(workspace, "link.txt"))).rejects.toThrow();
266+await expectPathMissing(path.join(workspace, "link.txt"));
263267await expect(fs.readFile(path.join(outside, "secret.txt"), "utf8")).resolves.toBe(
264268"classified",
265269);
@@ -292,7 +296,7 @@ describe("sandbox pinned mutation helper", () => {
292296await expect(fs.readFile(path.join(workspace, "from.txt"), "utf8")).resolves.toBe(
293297"payload",
294298);
295-await expect(fs.readFile(path.join(outside, "escape.txt"), "utf8")).rejects.toThrow();
299+await expectPathMissing(path.join(outside, "escape.txt"));
296300});
297301},
298302);
@@ -322,7 +326,7 @@ describe("sandbox pinned mutation helper", () => {
322326await expect(
323327fs.readFile(path.join(destRoot, "moved", "nested", "file.txt"), "utf8"),
324328).resolves.toBe("payload");
325-await expect(fs.stat(path.join(sourceRoot, "dir"))).rejects.toThrow();
329+await expectPathMissing(path.join(sourceRoot, "dir"));
326330});
327331},
328332);
@@ -353,7 +357,7 @@ describe("sandbox pinned mutation helper", () => {
353357354358expect(result.status).not.toBe(0);
355359expect(result.stderr).toMatch(/hardlinked file/i);
356-await expect(fs.stat(path.join(destRoot, "copied.txt"))).rejects.toThrow();
360+await expectPathMissing(path.join(destRoot, "copied.txt"));
357361await expect(fs.readFile(path.join(outsideRoot, "secret.txt"), "utf8")).resolves.toBe(
358362"classified",
359363);
@@ -397,7 +401,7 @@ describe("sandbox pinned mutation helper", () => {
397401await expect(
398402fs.readFile(path.join(sourceRoot, "dir", "nested", "linked.txt"), "utf8"),
399403).resolves.toBe("classified");
400-await expect(fs.stat(path.join(destRoot, "moved"))).rejects.toThrow();
404+await expectPathMissing(path.join(destRoot, "moved"));
401405await expect(fs.readdir(destRoot)).resolves.toEqual([]);
402406});
403407},
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。