Skip to content

Commit f2e02f1

Browse files
committed
test: isolate logger home fallback across platforms
1 parent b292bb0 commit f2e02f1

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

universal-refiner/tests/logger.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,20 @@ describe("RuntimeLogger", () => {
7070

7171
it("uses the home default and continues when file output fails", () => {
7272
const originalProfile = process.env.USERPROFILE;
73+
const originalHome = process.env.HOME;
7374
process.env.USERPROFILE = directory;
75+
process.env.HOME = directory;
7476
delete process.env.PROMPT_REFINER_GLOBAL_DIR;
7577
process.env.PROMPT_REFINER_LOG_LEVEL = "DEBUG";
76-
const blockedPath = path.join(os.homedir(), ".refiner");
78+
const blockedPath = path.join(directory, ".refiner");
7779
fs.writeFileSync(blockedPath, "not a directory");
7880

7981
RuntimeLogger.debug("still rendered", new Error("with stack"));
8082

8183
expect(consoleError).toHaveBeenCalledWith(expect.stringContaining("[DEBUG] still rendered"));
82-
process.env.USERPROFILE = originalProfile;
84+
if (originalProfile === undefined) delete process.env.USERPROFILE;
85+
else process.env.USERPROFILE = originalProfile;
86+
if (originalHome === undefined) delete process.env.HOME;
87+
else process.env.HOME = originalHome;
8388
});
8489
});

0 commit comments

Comments
 (0)