@@ -108,7 +108,11 @@ function createLaunchConfiguration(program: string, args: string, cwd: string, d
108108 return result ;
109109}
110110
111- function getLaunchConfigurationForVSTest ( server : OmniSharpServer , fileName : string , testMethod : string , testFrameworkName : string , debugEventListener : DebugEventListener ) : Promise < any > {
111+ function getLaunchConfigurationForVSTest ( server : OmniSharpServer , fileName : string , testMethod : string , testFrameworkName : string , debugEventListener : DebugEventListener , output : vscode . OutputChannel ) : Promise < any > {
112+ // Listen for test messages while getting start info.
113+ const disposable = server . onTestMessage ( e => {
114+ output . appendLine ( e . Message ) ;
115+ } ) ;
112116
113117 const request : protocol . V2 . DebugTestGetStartInfoRequest = {
114118 FileName : fileName ,
@@ -117,27 +121,38 @@ function getLaunchConfigurationForVSTest(server: OmniSharpServer, fileName: stri
117121 } ;
118122
119123 return serverUtils . debugTestGetStartInfo ( server , request )
120- . then ( response => createLaunchConfiguration ( response . FileName , response . Arguments , response . WorkingDirectory , debugEventListener . pipePath ( ) ) ) ;
124+ . then ( response => {
125+ disposable . dispose ( ) ;
126+ return createLaunchConfiguration ( response . FileName , response . Arguments , response . WorkingDirectory , debugEventListener . pipePath ( ) ) ;
127+ } ) ;
121128}
122129
123- function getLaunchConfigurationForLegacy ( server : OmniSharpServer , fileName : string , testMethod : string , testFrameworkName : string ) : Promise < any > {
130+ function getLaunchConfigurationForLegacy ( server : OmniSharpServer , fileName : string , testMethod : string , testFrameworkName : string , output : vscode . OutputChannel ) : Promise < any > {
131+ // Listen for test messages while getting start info.
132+ const disposable = server . onTestMessage ( e => {
133+ output . appendLine ( e . Message ) ;
134+ } ) ;
135+
124136 const request : protocol . V2 . GetTestStartInfoRequest = {
125137 FileName : fileName ,
126138 MethodName : testMethod ,
127139 TestFrameworkName : testFrameworkName
128140 } ;
129141
130142 return serverUtils . getTestStartInfo ( server , request )
131- . then ( response => createLaunchConfiguration ( response . Executable , response . Argument , response . WorkingDirectory , null ) ) ;
143+ . then ( response => {
144+ disposable . dispose ( ) ;
145+ return createLaunchConfiguration ( response . Executable , response . Argument , response . WorkingDirectory , null ) ;
146+ } ) ;
132147}
133148
134149
135- function getLaunchConfiguration ( server : OmniSharpServer , debugType : string , fileName : string , testMethod : string , testFrameworkName : string , debugEventListener : DebugEventListener ) : Promise < any > {
150+ function getLaunchConfiguration ( server : OmniSharpServer , debugType : string , fileName : string , testMethod : string , testFrameworkName : string , debugEventListener : DebugEventListener , output : vscode . OutputChannel ) : Promise < any > {
136151 switch ( debugType ) {
137152 case "legacy" :
138- return getLaunchConfigurationForLegacy ( server , fileName , testMethod , testFrameworkName ) ;
153+ return getLaunchConfigurationForLegacy ( server , fileName , testMethod , testFrameworkName , output ) ;
139154 case "vstest" :
140- return getLaunchConfigurationForVSTest ( server , fileName , testMethod , testFrameworkName , debugEventListener ) ;
155+ return getLaunchConfigurationForVSTest ( server , fileName , testMethod , testFrameworkName , debugEventListener , output ) ;
141156
142157 default :
143158 throw new Error ( `Unexpected debug type: ${ debugType } ` ) ;
@@ -150,8 +165,10 @@ export function debugDotnetTest(testMethod: string, fileName: string, testFramew
150165 // using VS Test. These require a different level of communication.
151166 let debugType : string ;
152167 let debugEventListener : DebugEventListener = null ;
153- let outputChannel = getTestOutputChannel ( ) ;
154- outputChannel . appendLine ( `Debugging method '${ testMethod } '.` ) ;
168+
169+ const output = getTestOutputChannel ( ) ;
170+
171+ output . appendLine ( `Debugging method '${ testMethod } '.` ) ;
155172
156173 return serverUtils . requestProjectInformation ( server , { FileName : fileName } )
157174 . then ( projectInfo => {
@@ -161,14 +178,14 @@ export function debugDotnetTest(testMethod: string, fileName: string, testFramew
161178 }
162179 else if ( projectInfo . MsBuildProject ) {
163180 debugType = "vstest" ;
164- debugEventListener = new DebugEventListener ( fileName , server , outputChannel ) ;
181+ debugEventListener = new DebugEventListener ( fileName , server , output ) ;
165182 return debugEventListener . start ( ) ;
166183 }
167184 else {
168185 throw new Error ( ) ;
169186 }
170187 } )
171- . then ( ( ) => getLaunchConfiguration ( server , debugType , fileName , testMethod , testFrameworkName , debugEventListener ) )
188+ . then ( ( ) => getLaunchConfiguration ( server , debugType , fileName , testMethod , testFrameworkName , debugEventListener , output ) )
172189 . then ( config => vscode . commands . executeCommand ( 'vscode.startDebug' , config ) )
173190 . catch ( reason => {
174191 vscode . window . showErrorMessage ( `Failed to start debugger: ${ reason } ` ) ;
@@ -238,6 +255,7 @@ class DebugEventListener {
238255 if ( DebugEventListener . s_activeInstance !== null ) {
239256 DebugEventListener . s_activeInstance . close ( ) ;
240257 }
258+
241259 DebugEventListener . s_activeInstance = this ;
242260
243261 this . _serverSocket = net . createServer ( ( socket : net . Socket ) => {
@@ -280,6 +298,7 @@ class DebugEventListener {
280298 this . _outputChannel . appendLine ( "Warning: Communications error on debugger event channel. " + err . message ) ;
281299 }
282300 } ) ;
301+
283302 this . _serverSocket . listen ( this . _pipePath , ( ) => {
284303 isStarted = true ;
285304 resolve ( ) ;
0 commit comments