@@ -13,11 +13,14 @@ import { fs } from '../../../shared'
1313import { findSshPath , findTypescriptCompiler , getVscodeCliPath } from '../../../shared/utilities/pathFind'
1414import * as programUtils from '../../../shared/utilities/programUtils'
1515
16+ function isWin ( ) : boolean {
17+ return process . platform === 'win32'
18+ }
19+
1620describe ( 'pathFind' , function ( ) {
1721 it ( 'findTypescriptCompiler()' , async function ( ) {
18- const iswin = process . platform === 'win32'
1922 const workspace = vscode . workspace . workspaceFolders ! [ 0 ]
20- const tscNodemodules = path . join ( workspace . uri . fsPath , `foo/bar/node_modules/.bin/tsc${ iswin ? '.cmd' : '' } ` )
23+ const tscNodemodules = path . join ( workspace . uri . fsPath , `foo/bar/node_modules/.bin/tsc${ isWin ( ) ? '.cmd' : '' } ` )
2124 await fs . delete ( tscNodemodules , { force : true } )
2225
2326 // The test workspace normally doesn't have node_modules so this will
@@ -46,16 +49,21 @@ describe('pathFind', function () {
4649
4750 describe ( 'findSshPath' , function ( ) {
4851 let tryRunStub : sinon . SinonStub
52+ // On Windows the first call to tryRun gives a valid path, which changes func behavior.
53+ // We can offset our call checks based on this.
54+ let callOffset : number
55+
4956 before ( function ( ) {
5057 tryRunStub = sinon . stub ( programUtils , 'tryRun' )
58+ callOffset = isWin ( ) ? 1 : 0
5159 } )
5260
5361 after ( function ( ) {
5462 tryRunStub . restore ( )
5563 } )
5664
5765 it ( 'first tries $PATH' , async function ( ) {
58- tryRunStub . onFirstCall ( ) . resolves ( true )
66+ tryRunStub . onCall ( callOffset ) . resolves ( true )
5967
6068 const result = await findSshPath ( false )
6169 assert . ok ( result )
@@ -64,8 +72,8 @@ describe('pathFind', function () {
6472 } )
6573
6674 it ( 'if $PATH fails, tries /usr/bin/ssh' , async function ( ) {
67- tryRunStub . onFirstCall ( ) . resolves ( false )
68- tryRunStub . onSecondCall ( ) . resolves ( true )
75+ tryRunStub . onCall ( callOffset ) . resolves ( false )
76+ tryRunStub . onCall ( callOffset + 1 ) . resolves ( true )
6977
7078 const result = await findSshPath ( false )
7179 assert . ok ( result )
@@ -74,7 +82,7 @@ describe('pathFind', function () {
7482 } )
7583
7684 it ( 'dry runs the resulting ssh' , async function ( ) {
77- tryRunStub . onFirstCall ( ) . resolves ( true )
85+ tryRunStub . onCall ( callOffset ) . resolves ( true )
7886 await findSshPath ( false )
7987 assert . ok ( tryRunStub . calledOnce )
8088 tryRunStub . resetHistory ( )
0 commit comments