From e16e3ada63166ee36ca19e230ef601143bf5e332 Mon Sep 17 00:00:00 2001 From: Jakub Chocholowicz Date: Mon, 15 Jun 2020 12:12:39 +0200 Subject: [PATCH] More changes --- .../Interfaces/Engine/IMultiTestRunFinalizationManager.cs | 1 - .../Client/Parallel/ParallelProxyExecutionManager.cs | 7 +++++++ .../DataCollection/ParallelDataCollectionEventsHandler.cs | 6 +++--- .../DataCollector/IDataCollectorAttachments.cs | 7 ++++++- .../CodeCoverageDataAttachmentsHandler.cs | 5 +++++ 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/IMultiTestRunFinalizationManager.cs b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/IMultiTestRunFinalizationManager.cs index b09c6f9339..e91b1da0d3 100644 --- a/src/Microsoft.TestPlatform.Common/Interfaces/Engine/IMultiTestRunFinalizationManager.cs +++ b/src/Microsoft.TestPlatform.Common/Interfaces/Engine/IMultiTestRunFinalizationManager.cs @@ -26,7 +26,6 @@ internal interface IMultiTestRunFinalizationManager /// 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/Client/Parallel/ParallelProxyExecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyExecutionManager.cs index 922541e63c..86df14a387 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyExecutionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyExecutionManager.cs @@ -14,11 +14,14 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; + using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing; using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; + using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.MultiTestRunFinalization; using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + using Microsoft.VisualStudio.TestPlatform.Utilities; /// /// ParallelProxyExecutionManager that manages parallel execution @@ -258,12 +261,16 @@ private ParallelRunEventsHandler GetEventsHandler(IProxyExecutionManager concurr { var concurrentManagerWithDataCollection = concurrentManager as ProxyExecutionManagerWithDataCollection; + // TODO : use TestPluginCache to iterate over all IDataCollectorAttachments + var finalizationManager = new MultiTestRunFinalizationManager(TestPlatformEventSource.Instance, new CodeCoverageDataAttachmentsHandler()); + return new ParallelDataCollectionEventsHandler( this.requestData, concurrentManagerWithDataCollection, this.currentRunEventsHandler, this, this.currentRunDataAggregator, + finalizationManager, concurrentManagerWithDataCollection.CancellationToken); } diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ParallelDataCollectionEventsHandler.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ParallelDataCollectionEventsHandler.cs index ed9d614743..c743622f2c 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ParallelDataCollectionEventsHandler.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ParallelDataCollectionEventsHandler.cs @@ -27,11 +27,11 @@ public ParallelDataCollectionEventsHandler(IRequestData requestData, ITestRunEventsHandler actualRunEventsHandler, IParallelProxyExecutionManager parallelProxyExecutionManager, ParallelRunDataAggregator runDataAggregator, + IMultiTestRunFinalizationManager finalizationManager, CancellationToken cancellationToken) : this(requestData, proxyExecutionManager, actualRunEventsHandler, parallelProxyExecutionManager, runDataAggregator, JsonDataSerializer.Instance) { - // TODO : use TestPluginCache to iterate over all IDataCollectorAttachments - this.finalizationManager = new MultiTestRunFinalizationManager(TestPlatformEventSource.Instance, new CodeCoverageDataAttachmentsHandler()); + this.finalizationManager = finalizationManager; this.cancellationToken = cancellationToken; } @@ -65,7 +65,7 @@ public override void HandleTestRunComplete( this.runDataAggregator.IsCanceled, this.runDataAggregator.IsAborted, this.runDataAggregator.GetAggregatedException(), - attachments, + attachments ?? runDataAggregator.RunContextAttachments, this.runDataAggregator.ElapsedTime); // Add Metrics from Test Host diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectorAttachments.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectorAttachments.cs index eff8238976..84df144523 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectorAttachments.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectorAttachments.cs @@ -12,12 +12,17 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection /// public interface IDataCollectorAttachments { + /// + /// Gets the attachment set after Test Run Session + /// + /// Gets the attachment set after Test Run Session + ICollection HandleDataCollectionAttachmentSets(ICollection dataCollectionAttachments); + /// /// Gets the attachment set after Test Run Session /// /// Gets the attachment set after Test Run Session ICollection HandleDataCollectionAttachmentSets(ICollection dataCollectionAttachments, CancellationToken cancellationToken); - // TODO: add new method /// /// Gets the attachment Uri, which is handled by current Collector diff --git a/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs b/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs index f2ceeac7f2..395b8b2451 100644 --- a/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs +++ b/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs @@ -31,6 +31,11 @@ public Uri GetExtensionUri() return CodeCoverageDataCollectorUri; } + public ICollection HandleDataCollectionAttachmentSets(ICollection dataCollectionAttachments) + { + return HandleDataCollectionAttachmentSets(dataCollectionAttachments, CancellationToken.None); + } + public ICollection HandleDataCollectionAttachmentSets(ICollection dataCollectionAttachments, CancellationToken cancellationToken) { if (dataCollectionAttachments != null && dataCollectionAttachments.Any())