File tree Expand file tree Collapse file tree
src/Platform/Microsoft.Testing.Platform/Hosts Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -205,22 +205,25 @@ protected override async Task<int> InternalRunAsync()
205205 await _logger . LogDebugAsync ( $ "Starting test host process") ;
206206 using IProcess testHostProcess = process . Start ( processStartInfo ) ;
207207
208- testHostProcess . Exited += ( sender , e ) =>
209- {
210- var processExited = sender as Process ;
211- _logger . LogDebug ( $ "Test host process exited, PID: '{ processExited ? . Id } '") ;
212- } ;
213-
208+ int ? testHostProcessId = null ;
214209 try
215210 {
216- await _logger . LogDebugAsync ( $ "Started test host process ' { testHostProcess . Id } ' HasExited: { testHostProcess . HasExited } " ) ;
211+ testHostProcessId = testHostProcess . Id ;
217212 }
218213 catch ( InvalidOperationException ) when ( testHostProcess . HasExited )
219214 {
220215 // Access PID can throw InvalidOperationException if the process has already exited:
221216 // System.InvalidOperationException: No process is associated with this object.
222217 }
223218
219+ testHostProcess . Exited += ( sender , e ) =>
220+ {
221+ var processExited = sender as Process ;
222+ _logger . LogDebug ( $ "Test host process exited, PID: '{ testHostProcessId } '") ;
223+ } ;
224+
225+ await _logger . LogDebugAsync ( $ "Started test host process '{ testHostProcessId } ' HasExited: { testHostProcess . HasExited } ") ;
226+
224227 string ? seconds = configuration [ PlatformConfigurationConstants . PlatformTestHostControllersManagerSingleConnectionNamedPipeServerWaitConnectionTimeoutSeconds ] ;
225228 int timeoutSeconds = seconds is null ? TimeoutHelper . DefaultHangTimeoutSeconds : int . Parse ( seconds , CultureInfo . InvariantCulture ) ;
226229 await _logger . LogDebugAsync ( $ "Setting PlatformTestHostControllersManagerSingleConnectionNamedPipeServerWaitConnectionTimeoutSeconds '{ timeoutSeconds } '") ;
You can’t perform that action at this time.
0 commit comments