Skip to content

Commit f31b034

Browse files
committed
test(shields): avoid marker check-use race
Signed-off-by: Julie Yaunches <jyaunches@nvidia.com>
1 parent db0494e commit f31b034

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/lib/shields/flow.test.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -990,11 +990,16 @@ describe("shields command flow", () => {
990990
});
991991

992992
expect(renameSpy).toHaveBeenCalledWith(expect.stringContaining(".tmp"), markerPath);
993-
expect(fs.lstatSync(markerPath).isSymbolicLink()).toBe(false);
994-
expect(JSON.parse(fs.readFileSync(markerPath, "utf-8"))).toMatchObject({
995-
pid: 4242,
996-
sandboxName: "openclaw",
997-
});
993+
const markerFd = fs.openSync(markerPath, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW);
994+
try {
995+
expect(fs.fstatSync(markerFd).isFile()).toBe(true);
996+
expect(JSON.parse(fs.readFileSync(markerFd, "utf-8"))).toMatchObject({
997+
pid: 4242,
998+
sandboxName: "openclaw",
999+
});
1000+
} finally {
1001+
fs.closeSync(markerFd);
1002+
}
9981003
expect(fs.readFileSync(markerTargetPath, "utf-8")).toBe(markerTarget);
9991004
},
10001005
);

0 commit comments

Comments
 (0)