forked from microsoft/vstest
/
DataCollectionLauncherFactory.cs
54 lines (48 loc) · 2.37 KB
/
DataCollectionLauncherFactory.cs
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
// 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;
using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities;
using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces;
/// <summary>
/// Factory for creating DataCollectionLauncher
/// </summary>
internal static class DataCollectionLauncherFactory
{
/// <summary>
/// The get data collector launcher.
/// </summary>
/// <returns>
/// The <see cref="IDataCollectionLauncher"/>.
/// </returns>
internal static IDataCollectionLauncher GetDataCollectorLauncher(IProcessHelper processHelper, string settingsXml)
{
// Always launch datacollector.exe if code coverage is configured.
if (!string.IsNullOrWhiteSpace(settingsXml))
{
var dataCollectionRunSettings = XmlRunSettingsUtilities.GetDataCollectionRunSettings(settingsXml);
foreach (var dataCollectorSettings in dataCollectionRunSettings.DataCollectorSettingsList)
{
if (dataCollectorSettings.FriendlyName!=null && dataCollectorSettings.FriendlyName.ToLower().Equals("event log"))
{
return new DefaultDataCollectionLauncher();
}
if(dataCollectorSettings.Uri!=null && dataCollectorSettings.Uri.ToString().ToLower().Equals(@"datacollector://Microsoft/EventLog/2.0"))
{
return new DefaultDataCollectionLauncher();
}
}
}
// Target Framework of DataCollection process and Runner should be same.
var currentProcessPath = processHelper.GetCurrentProcessFileName();
if (currentProcessPath.EndsWith("dotnet", StringComparison.OrdinalIgnoreCase)
|| currentProcessPath.EndsWith("dotnet.exe", StringComparison.OrdinalIgnoreCase))
{
return new DotnetDataCollectionLauncher();
}
return new DefaultDataCollectionLauncher();
}
}
}