mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-27 01:41:40 +00:00
test: disable Vitest fs cache on Windows
This commit is contained in:
@@ -22,6 +22,43 @@ describe("loadVitestExperimentalConfig", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("disables the filesystem module cache by default on Windows", () => {
|
||||
const originalRunnerOs = process.env.RUNNER_OS;
|
||||
process.env.RUNNER_OS = "Windows";
|
||||
try {
|
||||
expect(loadVitestExperimentalConfig({ RUNNER_OS: "Windows" })).toEqual({});
|
||||
} finally {
|
||||
if (originalRunnerOs === undefined) {
|
||||
delete process.env.RUNNER_OS;
|
||||
} else {
|
||||
process.env.RUNNER_OS = originalRunnerOs;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("still allows enabling the filesystem module cache explicitly on Windows", () => {
|
||||
const originalRunnerOs = process.env.RUNNER_OS;
|
||||
process.env.RUNNER_OS = "Windows";
|
||||
try {
|
||||
expect(
|
||||
loadVitestExperimentalConfig({
|
||||
RUNNER_OS: "Windows",
|
||||
OPENCLAW_VITEST_FS_MODULE_CACHE: "1",
|
||||
}),
|
||||
).toEqual({
|
||||
experimental: {
|
||||
fsModuleCache: true,
|
||||
},
|
||||
});
|
||||
} finally {
|
||||
if (originalRunnerOs === undefined) {
|
||||
delete process.env.RUNNER_OS;
|
||||
} else {
|
||||
process.env.RUNNER_OS = originalRunnerOs;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("allows disabling the filesystem module cache explicitly", () => {
|
||||
expect(
|
||||
loadVitestExperimentalConfig({
|
||||
|
||||
@@ -10,6 +10,14 @@ const isDisabled = (value: string | undefined): boolean => {
|
||||
return normalized === "0" || normalized === "false";
|
||||
};
|
||||
|
||||
const isWindowsEnv = (env: EnvMap, platform: NodeJS.Platform): boolean => {
|
||||
if (platform === "win32") {
|
||||
return true;
|
||||
}
|
||||
const runnerOs = env.RUNNER_OS?.trim().toLowerCase();
|
||||
return runnerOs === "windows";
|
||||
};
|
||||
|
||||
export function loadVitestExperimentalConfig(env: EnvMap = process.env): {
|
||||
experimental?: {
|
||||
fsModuleCache?: true;
|
||||
@@ -22,8 +30,12 @@ export function loadVitestExperimentalConfig(env: EnvMap = process.env): {
|
||||
importDurations?: { print: true };
|
||||
printImportBreakdown?: true;
|
||||
} = {};
|
||||
const windowsEnv = isWindowsEnv(env, process.platform);
|
||||
|
||||
if (!isDisabled(env.OPENCLAW_VITEST_FS_MODULE_CACHE)) {
|
||||
if (!windowsEnv && !isDisabled(env.OPENCLAW_VITEST_FS_MODULE_CACHE)) {
|
||||
experimental.fsModuleCache = true;
|
||||
}
|
||||
if (windowsEnv && isEnabled(env.OPENCLAW_VITEST_FS_MODULE_CACHE)) {
|
||||
experimental.fsModuleCache = true;
|
||||
}
|
||||
if (isEnabled(env.OPENCLAW_VITEST_IMPORT_DURATIONS)) {
|
||||
|
||||
Reference in New Issue
Block a user