Skip to content

Commit a237ff0

Browse files
test(skills): cover both platform branches of the harness path constants
The harness computes HOME_DIR, PROJECT_DIR and SHARED_DIR once at import time, so the branch the importing runner never takes stayed a partial on the patch. Re-import the module under each platform value and assert both sides, at the layer that already owns the harness.
1 parent 74c08f1 commit a237ff0

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

‎src/services/skills/__tests__/SkillsManager.spec.ts‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3259,3 +3259,46 @@ Instructions`)
32593259
})
32603260
})
32613261
})
3262+
3263+
describe("skillsTestHarness platform branches", () => {
3264+
// The harness computes its constants once, at import time, from process.platform, so the branch
3265+
// the importing runner never takes is only exercisable by re-importing the module with that
3266+
// platform value installed. Both sides are asserted so the patch coverage lands whichever runner
3267+
// computes the report, and the module registry is reset back afterwards for the tests above.
3268+
const harnessUnderPlatform = async (platform: NodeJS.Platform) => {
3269+
const original = Object.getOwnPropertyDescriptor(process, "platform")
3270+
Object.defineProperty(process, "platform", { value: platform, configurable: true, writable: true })
3271+
vi.resetModules()
3272+
try {
3273+
return await import("./skillsTestHarness")
3274+
} finally {
3275+
if (original) {
3276+
Object.defineProperty(process, "platform", original)
3277+
}
3278+
vi.resetModules()
3279+
}
3280+
}
3281+
3282+
it("takes the win32 branch of each path constant", async () => {
3283+
const harness = await harnessUnderPlatform("win32")
3284+
expect(harness.HOME_DIR).toBe("C:\\Users\\testuser")
3285+
expect(harness.PROJECT_DIR).toBe("C:\\test\\project")
3286+
expect(harness.SHARED_DIR).toBe("C:\\shared\\skills")
3287+
expect(harness.GLOBAL_ROO_DIR).toBe(path.join("C:\\Users\\testuser", ".roo"))
3288+
expect(harness.GLOBAL_AGENTS_DIR).toBe(path.join("C:\\Users\\testuser", ".agents"))
3289+
expect(harness.p("skills", "code")).toBe(path.join("skills", "code"))
3290+
expect(harness.enoent().code).toBe("ENOENT")
3291+
})
3292+
3293+
it("takes the posix branch of each path constant", async () => {
3294+
const harness = await harnessUnderPlatform("linux")
3295+
expect(harness.HOME_DIR).toBe("/home/user")
3296+
expect(harness.PROJECT_DIR).toBe("/test/project")
3297+
expect(harness.SHARED_DIR).toBe("/shared/skills")
3298+
expect(harness.GLOBAL_ROO_DIR).toBe(path.join("/home/user", ".roo"))
3299+
expect(harness.GLOBAL_AGENTS_DIR).toBe(path.join("/home/user", ".agents"))
3300+
expect(harness.p("skills", "code")).toBe(path.join("skills", "code"))
3301+
expect(harness.enoent().code).toBe("ENOENT")
3302+
expect(harness.enoent().message).toBe("ENOENT: no such file or directory")
3303+
})
3304+
})

0 commit comments

Comments
 (0)