-
Notifications
You must be signed in to change notification settings - Fork 346
Expand file tree
/
Copy pathParallelDataCollectionEventsHandler.cs
More file actions
78 lines (69 loc) · 4.01 KB
/
ParallelDataCollectionEventsHandler.cs
File metadata and controls
78 lines (69 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
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;
using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;
using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel;
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.Utilities;
internal class ParallelDataCollectionEventsHandler : ParallelRunEventsHandler
{
private readonly ParallelRunDataAggregator runDataAggregator;
private readonly IMultiTestRunFinalizationManager finalizationManager;
private readonly CancellationToken cancellationToken;
public ParallelDataCollectionEventsHandler(IRequestData requestData,
IProxyExecutionManager proxyExecutionManager,
ITestRunEventsHandler actualRunEventsHandler,
IParallelProxyExecutionManager parallelProxyExecutionManager,
ParallelRunDataAggregator runDataAggregator,
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.cancellationToken = cancellationToken;
}
internal ParallelDataCollectionEventsHandler(IRequestData requestData,
IProxyExecutionManager proxyExecutionManager,
ITestRunEventsHandler actualRunEventsHandler,
IParallelProxyExecutionManager parallelProxyExecutionManager,
ParallelRunDataAggregator runDataAggregator,
IDataSerializer dataSerializer) :
base(requestData, proxyExecutionManager, actualRunEventsHandler, parallelProxyExecutionManager, runDataAggregator, dataSerializer)
{
this.runDataAggregator = runDataAggregator;
}
/// <summary>
/// Handles the Run Complete event from a parallel proxy manager
/// </summary>
public override void HandleTestRunComplete(
TestRunCompleteEventArgs testRunCompleteArgs,
TestRunChangedEventArgs lastChunkArgs,
ICollection<AttachmentSet> runContextAttachments,
ICollection<string> executorUris)
{
var parallelRunComplete = HandleSingleTestRunComplete(testRunCompleteArgs, lastChunkArgs, runContextAttachments, executorUris);
if (parallelRunComplete)
{
Collection<AttachmentSet> attachments = finalizationManager.FinalizeMultiTestRunAsync(runDataAggregator.RunContextAttachments, cancellationToken).Result;
var completedArgs = new TestRunCompleteEventArgs(this.runDataAggregator.GetAggregatedRunStats(),
this.runDataAggregator.IsCanceled,
this.runDataAggregator.IsAborted,
this.runDataAggregator.GetAggregatedException(),
attachments,
this.runDataAggregator.ElapsedTime);
// Add Metrics from Test Host
completedArgs.Metrics = this.runDataAggregator.GetAggregatedRunDataMetrics();
HandleParallelTestRunComplete(completedArgs);
}
}
}
}