@@ -42,6 +42,11 @@ function echoEnvVarsCmd(varNames: string[]) {
4242 return `echo "${ varNames . map ( toShell ) . join ( ' ' ) } "`
4343}
4444
45+ function parseOutput ( output : string ) {
46+ // On Windows the final line is the result of the script.
47+ return isWin ( ) ? output . split ( '\n' ) . at ( - 1 ) : output
48+ }
49+
4550describe ( 'testSshConnection' , function ( ) {
4651 let testWorkspace : WorkspaceFolder
4752 let sshPath : string
@@ -70,7 +75,8 @@ describe('testSshConnection', function () {
7075 assert . strictEqual ( r . stdout , 'yes' )
7176 await createExecutableFile ( sshPath , echoEnvVarsCmd ( [ 'UNDEFINED_VAR' ] ) )
7277 const r2 = await testSshConnection ( process , 'localhost' , sshPath , 'test-user' , session )
73- assert . strictEqual ( r2 . stdout , '' )
78+
79+ assert . strictEqual ( parseOutput ( r2 . stdout ) , '' )
7480 } )
7581
7682 it ( 'injects new session into env' , async function ( ) {
@@ -93,14 +99,17 @@ describe('testSshConnection', function () {
9399
94100 await createExecutableFile ( sshPath , echoEnvVarsCmd ( [ 'SESSION_ID' , 'STREAM_URL' , 'TOKEN' ] ) )
95101 const r = await testSshConnection ( process , 'localhost' , sshPath , 'test-user' , newSession )
96- assert . strictEqual ( r . stdout , `${ newSession . SessionId } ${ newSession . StreamUrl } ${ newSession . TokenValue } ` )
102+ assert . strictEqual (
103+ parseOutput ( r . stdout ) ,
104+ `${ newSession . SessionId } ${ newSession . StreamUrl } ${ newSession . TokenValue } `
105+ )
97106 } )
98107
99108 it ( 'passes proper args to the ssh invoke' , async function ( ) {
100- const executableFileContent = isWin ( ) ? `echo "$Args[0] $Args[1] "` : `echo "$1 $2"`
109+ const executableFileContent = isWin ( ) ? `echo "%1 %2 "` : `echo "$1 $2"`
101110 const process = createBoundProcess ( async ( ) => ( { } ) )
102111 await createExecutableFile ( sshPath , executableFileContent )
103112 const r = await testSshConnection ( process , 'localhost' , sshPath , 'test-user' , { } as SSM . StartSessionResponse )
104- assert . strictEqual ( r . stdout , '-T test-user@localhost' )
113+ assert . strictEqual ( parseOutput ( r . stdout ) , '-T test-user@localhost' )
105114 } )
106115} )
0 commit comments