Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pdb Lock Issue #2029

Merged
merged 2 commits into from
May 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -417,13 +417,14 @@ private void SendMessageAndListenAndReportTestCases(IEnumerable<string> sources,
catch (Exception exception)
{
EqtTrace.Error("Aborting Test Discovery Operation: {0}", exception);

eventHandler.HandleLogMessage(TestMessageLevel.Error, TranslationLayerResources.AbortedTestsDiscovery);

var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(-1, true);
eventHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs, null);

CleanupCommunicationIfProcessExit();
// Earlier we were closing the connection with vstest.console in case of exceptions
// Removing that code because vstest.console might be in a healthy state and letting the client
// know of the error, so that the TL can wait for the next instruction from the client itself.
// Also, connection termination might not kill the process which could result in files being locked by testhost.
}

this.testPlatformEventSource.TranslationLayerDiscoveryStop();
Expand Down Expand Up @@ -483,7 +484,10 @@ private async Task SendMessageAndListenAndReportTestCasesAsync(IEnumerable<strin
var discoveryCompleteEventArgs = new DiscoveryCompleteEventArgs(-1, true);
eventHandler.HandleDiscoveryComplete(discoveryCompleteEventArgs, null);

CleanupCommunicationIfProcessExit();
// Earlier we were closing the connection with vstest.console in case of exceptions
// Removing that code because vstest.console might be in a healthy state and letting the client
// know of the error, so that the TL can wait for the next instruction from the client itself.
// Also, connection termination might not kill the process which could result in files being locked by testhost.
}

this.testPlatformEventSource.TranslationLayerDiscoveryStop();
Expand Down Expand Up @@ -537,7 +541,11 @@ private void SendMessageAndListenAndReportTestResults(string messageType, object
eventHandler.HandleLogMessage(TestMessageLevel.Error, TranslationLayerResources.AbortedTestsRun);
var completeArgs = new TestRunCompleteEventArgs(null, false, true, exception, null, TimeSpan.Zero);
eventHandler.HandleTestRunComplete(completeArgs, null, null, null);
this.CleanupCommunicationIfProcessExit();

// Earlier we were closing the connection with vstest.console in case of exceptions
// Removing that code because vstest.console might be in a healthy state and letting the client
// know of the error, so that the TL can wait for the next instruction from the client itself.
// Also, connection termination might not kill the process which could result in files being locked by testhost.
}

this.testPlatformEventSource.TranslationLayerExecutionStop();
Expand Down Expand Up @@ -591,21 +599,16 @@ private async Task SendMessageAndListenAndReportTestResultsAsync(string messageT
eventHandler.HandleLogMessage(TestMessageLevel.Error, TranslationLayerResources.AbortedTestsRun);
var completeArgs = new TestRunCompleteEventArgs(null, false, true, exception, null, TimeSpan.Zero);
eventHandler.HandleTestRunComplete(completeArgs, null, null, null);
this.CleanupCommunicationIfProcessExit();

// Earlier we were closing the connection with vstest.console in case of exceptions
// Removing that code because vstest.console might be in a healthy state and letting the client
// know of the error, so that the TL can wait for the next instruction from the client itself.
// Also, connection termination might not kill the process which could result in files being locked by testhost.
}

this.testPlatformEventSource.TranslationLayerExecutionStop();
}

private void CleanupCommunicationIfProcessExit()
{
if (this.processExitCancellationTokenSource != null
&& this.processExitCancellationTokenSource.IsCancellationRequested)
{
this.communicationManager.StopServer();
}
}

private Message TryReceiveMessage()
{
Message message = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ public async Task DiscoverTestsAsyncShouldAbortOnExceptionInSendMessage()
}

[TestMethod]
public void DiscoverTestsShouldAbortWhenProcessExited()
public void DiscoverTestsShouldLogErrorWhenProcessExited()
{
var mockHandler = new Mock<ITestDiscoveryEventsHandler2>();
var sources = new List<string> { "1.dll" };
Expand All @@ -698,11 +698,10 @@ public void DiscoverTestsShouldAbortWhenProcessExited()

manualEvent.WaitOne();
mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny<string>()), Times.Once);
this.mockCommunicationManager.Verify(cm => cm.StopServer(), Times.Once);
}

[TestMethod]
public async Task DiscoverTestsAsyncShouldAbortWhenProcessExited()
public async Task DiscoverTestsAsyncShouldLogErrorWhenProcessExited()
{
var mockHandler = new Mock<ITestDiscoveryEventsHandler2>();
var sources = new List<string> { "1.dll" };
Expand All @@ -723,7 +722,6 @@ public async Task DiscoverTestsAsyncShouldAbortWhenProcessExited()
await this.requestSenderAsync.DiscoverTestsAsync(sources, null, new TestPlatformOptions(), mockHandler.Object);

mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny<string>()), Times.Once);
this.mockCommunicationManager.Verify(cm => cm.StopServer(), Times.Once);
}

#endregion
Expand Down Expand Up @@ -1840,7 +1838,7 @@ public async Task StartTestRunAsyncShouldAbortOnExceptionInSendMessage()
}

[TestMethod]
public void StartTestRunShouldAbortOnProcessExited()
public void StartTestRunShouldLogErrorOnProcessExited()
{
var mockHandler = new Mock<ITestRunEventsHandler>();
var manualEvent = new ManualResetEvent(false);
Expand Down Expand Up @@ -1869,11 +1867,10 @@ public void StartTestRunShouldAbortOnProcessExited()

manualEvent.WaitOne();
mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny<string>()), Times.Once);
this.mockCommunicationManager.Verify(cm => cm.StopServer(), Times.Once);
}

[TestMethod]
public async Task StartTestRunAsyncShouldAbortOnProcessExited()
public async Task StartTestRunAsyncShouldLogErrorOnProcessExited()
{
var mockHandler = new Mock<ITestRunEventsHandler>();
var sources = new List<string> { "1.dll" };
Expand All @@ -1898,7 +1895,6 @@ public async Task StartTestRunAsyncShouldAbortOnProcessExited()
await this.requestSenderAsync.StartTestRunAsync(sources, null, null, mockHandler.Object);

mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny<string>()), Times.Once);
this.mockCommunicationManager.Verify(cm => cm.StopServer(), Times.Once);
}

#endregion
Expand Down