Skip to content

Commit 3d1740a

Browse files
committed
adjust windows cases
1 parent 6bec701 commit 3d1740a

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

packages/core/src/test/shared/utilities/pathFind.test.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,28 @@ describe('pathFind', function () {
7878
return
7979
}
8080
// On local non-windows, we can overwrite path and create our own executable to find.
81+
// On CI windows, we ensure executable exists in first path tried.
8182
if (!isWin()) {
8283
const workspace = await testutil.createTestWorkspaceFolder()
8384
const fakeSshPath = path.join(workspace.uri.fsPath, `ssh`)
8485

8586
testutil.setEnv(testutil.envWithNewPath(workspace.uri.fsPath))
8687

8788
await testutil.createExecutableFile(fakeSshPath, '')
89+
} else {
90+
const expectedWindowsPath = 'C:/Windows/System32/OpenSSH/ssh.exe'
91+
if (!(await fs.exists(expectedWindowsPath))) {
92+
await testutil.createExecutableFile(expectedWindowsPath, '')
93+
}
8894
}
8995

9096
const ssh = await findSshPath(false)
9197
assert.ok(ssh)
92-
const result = await tryRun(ssh, [])
98+
const result = await tryRun(ssh, [], 'yes')
9399
assert.ok(result)
94100
})
95101

96-
it('caches result from previous runs (CI + Local Non-Windows)', async function () {
102+
it('caches result from previous runs (Non-Windows)', async function () {
97103
// In CI, we can assume Windows machines will have ssh.
98104
if (!isCI() && isWin()) {
99105
return
@@ -104,22 +110,19 @@ describe('pathFind', function () {
104110
const tempLocation = path.join(workspace.uri.fsPath, 'temp-ssh')
105111
const fakeSshPath = path.join(workspace.uri.fsPath, `ssh`)
106112

107-
if (!isWin()) {
108-
testutil.setEnv(testutil.envWithNewPath(workspace.uri.fsPath))
113+
testutil.setEnv(testutil.envWithNewPath(workspace.uri.fsPath))
109114

110-
await testutil.createExecutableFile(fakeSshPath, '')
111-
}
115+
await testutil.createExecutableFile(fakeSshPath, '')
112116

113-
const ssh1 = await findSshPath(true)
114-
const originalSshPath = ssh1! === 'ssh' ? fakeSshPath : ssh1!
117+
const ssh1 = (await findSshPath(true))!
115118

116-
await fs.rename(originalSshPath, tempLocation)
119+
await fs.rename(ssh1, tempLocation)
117120

118121
const ssh2 = await findSshPath(true)
119122

120123
assert.strictEqual(ssh1, ssh2)
121124

122-
await fs.rename(tempLocation, originalSshPath)
125+
await fs.rename(tempLocation, ssh1)
123126
})
124127
})
125128
})

0 commit comments

Comments
 (0)