test: harden windows lsp test cleanup
This commit is contained in:
parent
ca2f8059a6
commit
7b9e20f2fa
@ -22,15 +22,17 @@ describe("lsp check", () => {
|
|||||||
// #given
|
// #given
|
||||||
const spawnSpy = spyOn(Bun, "spawn")
|
const spawnSpy = spyOn(Bun, "spawn")
|
||||||
|
|
||||||
// #when getting servers info
|
try {
|
||||||
await lsp.getLspServersInfo()
|
// #when getting servers info
|
||||||
|
await lsp.getLspServersInfo()
|
||||||
|
|
||||||
// #then should not spawn which
|
// #then should not spawn which
|
||||||
const calls = spawnSpy.mock.calls
|
const calls = spawnSpy.mock.calls
|
||||||
const whichCalls = calls.filter((c) => Array.isArray(c) && Array.isArray(c[0]) && c[0][0] === "which")
|
const whichCalls = calls.filter((c) => Array.isArray(c) && Array.isArray(c[0]) && c[0][0] === "which")
|
||||||
expect(whichCalls.length).toBe(0)
|
expect(whichCalls.length).toBe(0)
|
||||||
|
} finally {
|
||||||
spawnSpy.mockRestore()
|
spawnSpy.mockRestore()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -24,14 +24,20 @@ describe("isServerInstalled", () => {
|
|||||||
console.error(`Failed to clean up temp dir: ${e}`)
|
console.error(`Failed to clean up temp dir: ${e}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const keys = ["PATH", "Path", "PATHEXT"]
|
const pathVal = savedEnv.PATH ?? savedEnv.Path
|
||||||
for (const key of keys) {
|
if (pathVal === undefined) {
|
||||||
const val = savedEnv[key]
|
delete process.env.PATH
|
||||||
if (val === undefined) {
|
delete process.env.Path
|
||||||
delete process.env[key]
|
} else {
|
||||||
} else {
|
process.env.PATH = pathVal
|
||||||
process.env[key] = val
|
process.env.Path = pathVal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const pathextVal = savedEnv.PATHEXT
|
||||||
|
if (pathextVal === undefined) {
|
||||||
|
delete process.env.PATHEXT
|
||||||
|
} else {
|
||||||
|
process.env.PATHEXT = pathextVal
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user