mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 11:48:38 +00:00
test: tighten wsl detection coverage
This commit is contained in:
@@ -59,6 +59,13 @@ describe("wsl detection", () => {
|
|||||||
expect(readFileSyncMock).toHaveBeenCalledWith("/proc/version", "utf8");
|
expect(readFileSyncMock).toHaveBeenCalledWith("/proc/version", "utf8");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("returns false when sync detection cannot read /proc/version", () => {
|
||||||
|
readFileSyncMock.mockImplementationOnce(() => {
|
||||||
|
throw new Error("ENOENT");
|
||||||
|
});
|
||||||
|
expect(isWSLSync()).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
it.each(["Linux version 6.6.0-1-microsoft-standard-WSL2", "Linux version 6.6.0-1-wsl2"])(
|
it.each(["Linux version 6.6.0-1-microsoft-standard-WSL2", "Linux version 6.6.0-1-wsl2"])(
|
||||||
"detects WSL2 sync from kernel version: %s",
|
"detects WSL2 sync from kernel version: %s",
|
||||||
(kernelVersion) => {
|
(kernelVersion) => {
|
||||||
@@ -68,6 +75,12 @@ describe("wsl detection", () => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it("returns false for WSL2 sync when WSL is detected but no WSL2 markers exist", () => {
|
||||||
|
readFileSyncMock.mockReturnValueOnce("Linux version 4.4.0-19041-Microsoft");
|
||||||
|
readFileSyncMock.mockReturnValueOnce("Linux version 4.4.0-19041-Microsoft");
|
||||||
|
expect(isWSL2Sync()).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
it("returns false for sync detection on non-linux platforms", () => {
|
it("returns false for sync detection on non-linux platforms", () => {
|
||||||
setPlatform("darwin");
|
setPlatform("darwin");
|
||||||
expect(isWSLSync()).toBe(false);
|
expect(isWSLSync()).toBe(false);
|
||||||
@@ -88,6 +101,13 @@ describe("wsl detection", () => {
|
|||||||
expect(readFileMock).toHaveBeenCalledTimes(2);
|
expect(readFileMock).toHaveBeenCalledTimes(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("short-circuits async detection from WSL env vars without reading osrelease", async () => {
|
||||||
|
process.env.WSL_DISTRO_NAME = "Ubuntu";
|
||||||
|
|
||||||
|
await expect(isWSL()).resolves.toBe(true);
|
||||||
|
expect(readFileMock).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
it("returns false when async WSL detection cannot read osrelease", async () => {
|
it("returns false when async WSL detection cannot read osrelease", async () => {
|
||||||
readFileMock.mockRejectedValueOnce(new Error("ENOENT"));
|
readFileMock.mockRejectedValueOnce(new Error("ENOENT"));
|
||||||
await expect(isWSL()).resolves.toBe(false);
|
await expect(isWSL()).resolves.toBe(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user