let isWSLEnv: typeofimport("./wsl.js").isWSLEnv;
let isWSLSync: typeofimport("./wsl.js").isWSLSync;
let isWSL2Sync: typeofimport("./wsl.js").isWSL2Sync;
let isWSL: typeofimport("./wsl.js").isWSL;
let resetWSLStateForTests: typeofimport("./wsl.js").resetWSLStateForTests;
it("reads /proc/version for sync WSL detection when env vars are absent", () => {
readFileSyncMock.mockReturnValueOnce("Linux version 6.6.0-1-microsoft-standard-WSL2");
expect(isWSLSync()).toBe(true);
expect(readFileSyncMock).toHaveBeenCalledWith("/proc/version", "utf8");
});
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",
(kernelVersion) => {
readFileSyncMock.mockReturnValueOnce(kernelVersion);
readFileSyncMock.mockReturnValueOnce(kernelVersion);
expect(isWSL2Sync()).toBe(true);
},
);
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", () => {
setPlatform("darwin");
expect(isWSLSync()).toBe(false);
expect(isWSL2Sync()).toBe(false);
expect(readFileSyncMock).not.toHaveBeenCalled();
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.