diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/IMultiTestRunFinalizationManager.cs b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/IMultiTestRunFinalizationManager.cs
index 7a82cd3ccd..b09c6f9339 100644
--- a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/IMultiTestRunFinalizationManager.cs
+++ b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/IMultiTestRunFinalizationManager.cs
@@ -3,6 +3,7 @@
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Threading;
using System.Threading.Tasks;
@@ -14,11 +15,19 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine
internal interface IMultiTestRunFinalizationManager
{
///
- /// Finalizes multi test run
+ /// Finalizes multi test run and provides results through handler
///
/// Attachments
/// EventHandler for handling multi test run finalization events from Engine
/// Cancellation token
Task FinalizeMultiTestRunAsync(ICollection attachments, IMultiTestRunFinalizationEventsHandler eventHandler, CancellationToken cancellationToken);
+
+ ///
+ /// Finalizes multi test
+ ///
+ /// Attachments
+ /// EventHandler for handling multi test run finalization events from Engine
+ /// Cancellation token
+ Task> FinalizeMultiTestRunAsync(ICollection attachments, CancellationToken cancellationToken);
}
}
diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ParallelDataCollectionEventsHandler.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ParallelDataCollectionEventsHandler.cs
index aa3e56de62..ed9d614743 100644
--- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ParallelDataCollectionEventsHandler.cs
+++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ParallelDataCollectionEventsHandler.cs
@@ -4,6 +4,7 @@
namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection
{
using System.Collections.Generic;
+ using System.Collections.ObjectModel;
using System.Threading;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces;
@@ -58,13 +59,13 @@ public override void HandleTestRunComplete(
if (parallelRunComplete)
{
- finalizationManager.FinalizeMultiTestRunAsync(runDataAggregator.RunContextAttachments, null, cancellationToken).Wait();
+ Collection attachments = finalizationManager.FinalizeMultiTestRunAsync(runDataAggregator.RunContextAttachments, cancellationToken).Result;
var completedArgs = new TestRunCompleteEventArgs(this.runDataAggregator.GetAggregatedRunStats(),
this.runDataAggregator.IsCanceled,
this.runDataAggregator.IsAborted,
this.runDataAggregator.GetAggregatedException(),
- this.runDataAggregator.RunContextAttachments,
+ attachments,
this.runDataAggregator.ElapsedTime);
// Add Metrics from Test Host
diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/MultiTestRunFinalization/MultiTestRunFinalizationManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/MultiTestRunFinalization/MultiTestRunFinalizationManager.cs
index 3099fc2ccb..2eb388eeeb 100644
--- a/src/Microsoft.TestPlatform.CrossPlatEngine/MultiTestRunFinalization/MultiTestRunFinalizationManager.cs
+++ b/src/Microsoft.TestPlatform.CrossPlatEngine/MultiTestRunFinalization/MultiTestRunFinalizationManager.cs
@@ -32,19 +32,25 @@ public MultiTestRunFinalizationManager(ITestPlatformEventSource testPlatformEven
this.dataCollectorAttachmentsHandlers = dataCollectorAttachmentsHandlers ?? throw new ArgumentNullException(nameof(dataCollectorAttachmentsHandlers));
}
- ///
- /// Finalizes multi test run
- ///
- /// Attachments
- /// EventHandler for handling multi test run finalization events from Engine
- /// Cancellation token
+ ///
public async Task FinalizeMultiTestRunAsync(ICollection attachments, IMultiTestRunFinalizationEventsHandler eventHandler, CancellationToken cancellationToken)
+ {
+ await InternalFinalizeMultiTestRunAsync(new Collection(attachments.ToList()), eventHandler, cancellationToken);
+ }
+
+ ///
+ public Task> FinalizeMultiTestRunAsync(ICollection attachments, CancellationToken cancellationToken)
+ {
+ return InternalFinalizeMultiTestRunAsync(new Collection(attachments.ToList()), null, cancellationToken);
+ }
+
+ private async Task> InternalFinalizeMultiTestRunAsync(Collection attachments, IMultiTestRunFinalizationEventsHandler eventHandler, CancellationToken cancellationToken)
{
try
{
- cancellationToken.ThrowIfCancellationRequested();
+ testPlatformEventSource.MultiTestRunFinalizationStart(attachments?.Count ?? 0);
- testPlatformEventSource.MultiTestRunFinalizationStart(attachments.Count);
+ cancellationToken.ThrowIfCancellationRequested();
var taskCompletionSource = new TaskCompletionSource