@@ -129,6 +129,8 @@ export function debugDotnetTest(testMethod: string, fileName: string, testFramew
129129 // using VS Test. These require a different level of communication.
130130 let debugType : string ;
131131 let debugEventListener : DebugEventListener = null ;
132+ let outputChannel = getTestOutputChannel ( ) ;
133+ outputChannel . appendLine ( `Debugging method '${ testMethod } '.` ) ;
132134
133135 return serverUtils . requestProjectInformation ( server , { FileName : fileName } )
134136 . then ( projectInfo => {
@@ -138,7 +140,7 @@ export function debugDotnetTest(testMethod: string, fileName: string, testFramew
138140 }
139141 else if ( projectInfo . MsBuildProject ) {
140142 debugType = "vstest" ;
141- debugEventListener = new DebugEventListener ( ) ;
143+ debugEventListener = new DebugEventListener ( fileName , server , outputChannel ) ;
142144 return debugEventListener . start ( ) ;
143145 }
144146 else {
@@ -149,13 +151,6 @@ export function debugDotnetTest(testMethod: string, fileName: string, testFramew
149151 return getLaunchConfiguration ( server , debugType , fileName , testMethod , testFrameworkName , debugEventListener ) ;
150152 } )
151153 . then ( config => vscode . commands . executeCommand ( 'vscode.startDebug' , config ) )
152- . then ( ( ) => {
153- // For VS Test, we need to signal to start the test run after the debugger has launched.
154- // TODO: Need to find out when the debugger has actually launched. This is currently a race.
155- if ( debugType === "vstest" ) {
156- serverUtils . debugTestRun ( server , { FileName : fileName } ) ;
157- }
158- } )
159154 . catch ( reason => {
160155 vscode . window . showErrorMessage ( `Failed to start debugger: ${ reason } ` ) ;
161156 if ( debugEventListener != null ) {
@@ -188,21 +183,25 @@ export function updateCodeLensForTest(bucket: vscode.CodeLens[], fileName: strin
188183
189184class DebugEventListener {
190185 static s_activeInstance : DebugEventListener = null ;
191- _serverSocket : net . Server ;
192- _pipePath : string ;
186+ _fileName : string ;
187+ _server : OmniSharpServer ;
193188 _outputChannel : vscode . OutputChannel ;
189+ _pipePath : string ;
190+
191+ _serverSocket : net . Server ;
194192 _isClosed : boolean = false ;
195193
196- constructor ( ) {
194+ constructor ( fileName : string , server : OmniSharpServer , outputChannel : vscode . OutputChannel ) {
195+ this . _fileName = fileName ;
196+ this . _server = server ;
197+ this . _outputChannel = outputChannel ;
197198 // NOTE: The max pipe name on OSX is fairly small, so this name shouldn't bee too long.
198199 const pipeSuffix = "TestDebugEvents-" + process . pid ;
199200 if ( os . platform ( ) === 'win32' ) {
200201 this . _pipePath = "\\\\.\\pipe\\Microsoft.VSCode.CSharpExt." + pipeSuffix ;
201202 } else {
202203 this . _pipePath = path . join ( utils . getExtensionPath ( ) , "." + pipeSuffix ) ;
203204 }
204-
205- this . _outputChannel = getTestOutputChannel ( ) ;
206205 }
207206
208207 public start ( ) : Promise < void > {
@@ -225,8 +224,12 @@ class DebugEventListener {
225224 }
226225
227226 if ( event . eventType === DebuggerEventsProtocol . EventType . ProcessLaunched ) {
228- // TODO: notify OmniSharp
227+ let processLaunchedEvent = < DebuggerEventsProtocol . ProcessLaunchedEvent > ( event ) ;
228+ this . _outputChannel . appendLine ( `Started debugging process #${ processLaunchedEvent . targetProcessId } .` ) ;
229+ // TODO: provide the process id to OmniSharp
230+ serverUtils . debugTestRun ( this . _server , { FileName : this . _fileName } ) ;
229231 } else if ( event . eventType === DebuggerEventsProtocol . EventType . DebuggingStopped ) {
232+ this . _outputChannel . appendLine ( "Debugging complete." ) ;
230233 this . fireDebuggingStopped ( ) ;
231234 }
232235 } ) ;
@@ -278,7 +281,7 @@ class DebugEventListener {
278281 }
279282
280283 // TODO: notify omniSharp
281-
284+
282285 this . close ( ) ;
283286 }
284287
0 commit comments