Skip to content

Commit

Permalink
Handling the TaskCanceledException in the results.publish command (mi…
Browse files Browse the repository at this point in the history
…crosoft#2960)

* Handling the TaskCanceledException in the results.publish command

* Removed repro code

* Removing dummy code added to test

Co-authored-by: Shailesh Singh Kushwaha <[email protected]>
  • Loading branch information
navin22 and shailesh-sk authored May 5, 2020
1 parent 65f92f7 commit cfe3cfe
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,10 @@ private async Task<bool> PublishAllTestResultsToSingleTestRunAsync(List<string>
StoreTestRunSummaryInEnvVar(testRunSummary);
}
}
catch (Exception ex) when (!(ex is OperationCanceledException))
catch (Exception ex) when (!(ex is OperationCanceledException && _executionContext.CancellationToken.IsCancellationRequested))
{
//Do not fail the task.
// Not catching all the operationcancelled exceptions, as the pipeline cancellation should cancel the command as well.
// Do not fail the task.
LogPublishTestResultsFailureWarning(ex);
}
return isTestRunOutcomeFailed;
Expand Down Expand Up @@ -263,7 +264,6 @@ private async Task<bool> PublishToNewTestRunPerTestResultFileAsync(List<string>

bool changeTestRunTitle = resultFiles.Count > 1;
TestRunSummary testRunSummary = new TestRunSummary();

foreach (var files in groupedFiles)
{
// Publish separate test run for each result file that has results.
Expand Down Expand Up @@ -325,9 +325,10 @@ private async Task<bool> PublishToNewTestRunPerTestResultFileAsync(List<string>

StoreTestRunSummaryInEnvVar(testRunSummary);
}
catch (Exception ex) when (!(ex is OperationCanceledException))
catch (Exception ex) when (!(ex is OperationCanceledException && _executionContext.CancellationToken.IsCancellationRequested))
{
//Do not fail the task.
// Not catching all the operationcancelled exceptions, as the pipeline cancellation should cancel the command as well.
// Do not fail the task.
LogPublishTestResultsFailureWarning(ex);
}
return isTestRunOutcomeFailed;
Expand Down

0 comments on commit cfe3cfe

Please sign in to comment.