Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data collectors present in runsettings not working when collect args are present #1510

Merged
merged 1 commit into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions src/vstest.console/Processors/CollectArgumentProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,21 +144,6 @@ internal static void EnableDataCollectorUsingFriendlyName(string argument, DataC
}
}

private static void DisableUnConfiguredDataCollectors(DataCollectionRunSettings dataCollectionRunSettings)
{
foreach (var dataCollectorSetting in dataCollectionRunSettings.DataCollectorSettingsList)
{
if (EnabledDataCollectors.Contains(dataCollectorSetting.FriendlyName.ToLower()))
{
dataCollectorSetting.IsEnabled = true;
}
else
{
dataCollectorSetting.IsEnabled = false;
}
}
}

private static bool DoesDataCollectorSettingsExist(string friendlyName,
DataCollectionRunSettings dataCollectionRunSettings,
out DataCollectorSettings dataCollectorSettings)
Expand Down Expand Up @@ -192,12 +177,6 @@ internal static void AddDataCollectorToRunSettings(string argument, IRunSettings
{
dataCollectionRunSettings = new DataCollectionRunSettings();
}
else
{
// By default, all data collectors present in run settings are enabled, if enabled attribute is not specified.
// So explicitely disable those data collectors and enable those which are specified.
DisableUnConfiguredDataCollectors(dataCollectionRunSettings);
}

// Add data collectors if not already present, enable if already present.
EnableDataCollectorUsingFriendlyName(argument, dataCollectionRunSettings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void InitializeShouldEnableDataCollectorIfDisabledInRunSettings()
}

[TestMethod]
public void InitializeShouldDisableOtherDataCollectors()
public void InitializeShouldNotDisableOtherDataCollectorsIfEnabled()
{
var runsettingsString = string.Format(DefaultRunSettings, "<DataCollector friendlyName=\"MyDataCollector\" enabled=\"False\" /><DataCollector friendlyName=\"MyDataCollector1\" enabled=\"True\" />");
var runsettings = new RunSettings();
Expand All @@ -146,6 +146,20 @@ public void InitializeShouldDisableOtherDataCollectors()
this.executor.Initialize("MyDataCollector");
this.executor.Initialize("MyDataCollector2");

Assert.AreEqual("<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<RunSettings>\r\n <DataCollectionRunSettings>\r\n <DataCollectors>\r\n <DataCollector friendlyName=\"MyDataCollector\" enabled=\"True\" />\r\n <DataCollector friendlyName=\"MyDataCollector1\" enabled=\"True\" />\r\n <DataCollector friendlyName=\"MyDataCollector2\" enabled=\"True\" />\r\n </DataCollectors>\r\n </DataCollectionRunSettings>\r\n</RunSettings>", this.settingsProvider.ActiveRunSettings.SettingsXml);
}

[TestMethod]
public void InitializeShouldNotEnableOtherDataCollectorsIfDisabled()
{
var runsettingsString = string.Format(DefaultRunSettings, "<DataCollector friendlyName=\"MyDataCollector\" enabled=\"False\" /><DataCollector friendlyName=\"MyDataCollector1\" enabled=\"False\" />");
var runsettings = new RunSettings();
runsettings.LoadSettingsXml(runsettingsString);
this.settingsProvider.SetActiveRunSettings(runsettings);

this.executor.Initialize("MyDataCollector");
this.executor.Initialize("MyDataCollector2");

Assert.AreEqual("<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<RunSettings>\r\n <DataCollectionRunSettings>\r\n <DataCollectors>\r\n <DataCollector friendlyName=\"MyDataCollector\" enabled=\"True\" />\r\n <DataCollector friendlyName=\"MyDataCollector1\" enabled=\"False\" />\r\n <DataCollector friendlyName=\"MyDataCollector2\" enabled=\"True\" />\r\n </DataCollectors>\r\n </DataCollectionRunSettings>\r\n</RunSettings>", this.settingsProvider.ActiveRunSettings.SettingsXml);
}

Expand Down