diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameCollector.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameCollector.cs index 3f8ad9bcd3..57b4cd624f 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameCollector.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameCollector.cs @@ -348,6 +348,7 @@ private void ValidateAndAddHangBasedProcessDumpParameters(XmlElement collectDump break; + // allow HangDumpType attribute to be used on the hang dump this is the prefered way case XmlAttribute attribute when string.Equals(attribute.Name, Constants.HangDumpTypeKey, StringComparison.OrdinalIgnoreCase): if (string.Equals(attribute.Value, Constants.FullConfigurationValue, StringComparison.OrdinalIgnoreCase) || string.Equals(attribute.Value, Constants.MiniConfigurationValue, StringComparison.OrdinalIgnoreCase)) @@ -361,6 +362,20 @@ private void ValidateAndAddHangBasedProcessDumpParameters(XmlElement collectDump break; + // allow DumpType attribute to be used on the hang dump for backwards compatibility + case XmlAttribute attribute when string.Equals(attribute.Name, Constants.DumpTypeKey, StringComparison.OrdinalIgnoreCase): + + if (string.Equals(attribute.Value, Constants.FullConfigurationValue, StringComparison.OrdinalIgnoreCase) || string.Equals(attribute.Value, Constants.MiniConfigurationValue, StringComparison.OrdinalIgnoreCase)) + { + this.processFullDumpEnabled = string.Equals(attribute.Value, Constants.FullConfigurationValue, StringComparison.OrdinalIgnoreCase); + } + else + { + this.logger.LogWarning(this.context.SessionDataCollectionContext, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterValueIncorrect, attribute.Name, Constants.FullConfigurationValue, Constants.MiniConfigurationValue)); + } + + break; + default: this.logger.LogWarning(this.context.SessionDataCollectionContext, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterKeyIncorrect, blameAttribute.Name)); @@ -454,7 +469,7 @@ private void SessionEndedHandler(object sender, SessionEndEventArgs args) { try { - var dumpFiles = this.processDumpUtility.GetDumpFiles(); + var dumpFiles = this.processDumpUtility.GetDumpFiles(warnOnNoDumpFiles: this.collectDumpAlways); foreach (var dumpFile in dumpFiles) { if (!string.IsNullOrEmpty(dumpFile)) diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IProcessDumpUtility.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IProcessDumpUtility.cs index 74acf34e53..aca460dc0d 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IProcessDumpUtility.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IProcessDumpUtility.cs @@ -11,10 +11,11 @@ public interface IProcessDumpUtility /// /// Get generated dump files /// + /// Writes warning when no dump file is found. /// /// Path of dump file /// - IEnumerable GetDumpFiles(); + IEnumerable GetDumpFiles(bool warnOnNoDumpFiles = true); /// /// Launch proc dump process diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessDumpUtility.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessDumpUtility.cs index 6065f1c4e3..8c7166e815 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessDumpUtility.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessDumpUtility.cs @@ -51,7 +51,7 @@ public ProcessDumpUtility(IProcessHelper processHelper, IFileHelper fileHelper, }; /// - public IEnumerable GetDumpFiles() + public IEnumerable GetDumpFiles(bool warnOnNoDumpFiles = true) { if (!this.wasHangDumped) { @@ -82,7 +82,7 @@ public IEnumerable GetDumpFiles() } } - if (!foundDumps.Any()) + if (warnOnNoDumpFiles && !foundDumps.Any()) { EqtTrace.Error($"ProcessDumpUtility.GetDumpFile: Could not find any dump file in {this.hangDumpDirectory}."); throw new FileNotFoundException(Resources.Resources.DumpFileNotGeneratedErrorMessage); diff --git a/src/package/VSIXProject/TestPlatform.csproj b/src/package/VSIXProject/TestPlatform.csproj index a830fb53bd..ca48090d5c 100644 --- a/src/package/VSIXProject/TestPlatform.csproj +++ b/src/package/VSIXProject/TestPlatform.csproj @@ -238,6 +238,22 @@ + + + + + + + + + + + + + + + + diff --git a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/BlameCollectorTests.cs b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/BlameCollectorTests.cs index 880e742290..7a036fdda3 100644 --- a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/BlameCollectorTests.cs +++ b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/BlameCollectorTests.cs @@ -172,7 +172,7 @@ public void InitializeWithDumpForHangShouldCaptureADumpOnTimeout() this.mockFileHelper.Setup(x => x.Exists(It.Is(y => y == "abc_hang.dmp"))).Returns(true); this.mockFileHelper.Setup(x => x.GetFullPath(It.Is(y => y == "abc_hang.dmp"))).Returns("abc_hang.dmp"); this.mockProcessDumpUtility.Setup(x => x.StartHangBasedProcessDump(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>())); - this.mockProcessDumpUtility.Setup(x => x.GetDumpFiles()).Returns(new[] { dumpFile }); + this.mockProcessDumpUtility.Setup(x => x.GetDumpFiles(true)).Returns(new[] { dumpFile }); this.mockDataCollectionSink.Setup(x => x.SendFileAsync(It.IsAny())).Callback(() => hangBasedDumpcollected.Set()); this.blameDataCollector.Initialize( @@ -184,7 +184,7 @@ public void InitializeWithDumpForHangShouldCaptureADumpOnTimeout() hangBasedDumpcollected.Wait(1000); this.mockProcessDumpUtility.Verify(x => x.StartHangBasedProcessDump(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>()), Times.Once); - this.mockProcessDumpUtility.Verify(x => x.GetDumpFiles(), Times.Once); + this.mockProcessDumpUtility.Verify(x => x.GetDumpFiles(true), Times.Once); this.mockDataCollectionSink.Verify(x => x.SendFileAsync(It.Is(y => y.Path == dumpFile)), Times.Once); } @@ -206,7 +206,7 @@ public void InitializeWithDumpForHangShouldCaptureKillTestHostOnTimeoutEvenIfGet this.mockFileHelper.Setup(x => x.Exists(It.Is(y => y == "abc_hang.dmp"))).Returns(true); this.mockFileHelper.Setup(x => x.GetFullPath(It.Is(y => y == "abc_hang.dmp"))).Returns("abc_hang.dmp"); this.mockProcessDumpUtility.Setup(x => x.StartHangBasedProcessDump(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>())); - this.mockProcessDumpUtility.Setup(x => x.GetDumpFiles()).Callback(() => hangBasedDumpcollected.Set()).Throws(new Exception("Some exception")); + this.mockProcessDumpUtility.Setup(x => x.GetDumpFiles(true)).Callback(() => hangBasedDumpcollected.Set()).Throws(new Exception("Some exception")); this.blameDataCollector.Initialize( this.GetDumpConfigurationElement(false, false, true, 0), @@ -217,7 +217,7 @@ public void InitializeWithDumpForHangShouldCaptureKillTestHostOnTimeoutEvenIfGet hangBasedDumpcollected.Wait(1000); this.mockProcessDumpUtility.Verify(x => x.StartHangBasedProcessDump(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>()), Times.Once); - this.mockProcessDumpUtility.Verify(x => x.GetDumpFiles(), Times.Once); + this.mockProcessDumpUtility.Verify(x => x.GetDumpFiles(true), Times.Once); } /// @@ -239,7 +239,7 @@ public void InitializeWithDumpForHangShouldCaptureKillTestHostOnTimeoutEvenIfAtt this.mockFileHelper.Setup(x => x.Exists(It.Is(y => y == "abc_hang.dmp"))).Returns(true); this.mockFileHelper.Setup(x => x.GetFullPath(It.Is(y => y == "abc_hang.dmp"))).Returns("abc_hang.dmp"); this.mockProcessDumpUtility.Setup(x => x.StartHangBasedProcessDump(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>())); - this.mockProcessDumpUtility.Setup(x => x.GetDumpFiles()).Returns(new[] { dumpFile }); + this.mockProcessDumpUtility.Setup(x => x.GetDumpFiles(true)).Returns(new[] { dumpFile }); this.mockDataCollectionSink.Setup(x => x.SendFileAsync(It.IsAny())).Callback(() => hangBasedDumpcollected.Set()).Throws(new Exception("Some other exception")); this.blameDataCollector.Initialize( @@ -251,7 +251,7 @@ public void InitializeWithDumpForHangShouldCaptureKillTestHostOnTimeoutEvenIfAtt hangBasedDumpcollected.Wait(1000); this.mockProcessDumpUtility.Verify(x => x.StartHangBasedProcessDump(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>()), Times.Once); - this.mockProcessDumpUtility.Verify(x => x.GetDumpFiles(), Times.Once); + this.mockProcessDumpUtility.Verify(x => x.GetDumpFiles(true), Times.Once); this.mockDataCollectionSink.Verify(x => x.SendFileAsync(It.Is(y => y.Path == dumpFile)), Times.Once); } @@ -366,7 +366,7 @@ public void TriggerSessionEndedHandlerShouldGetDumpFileIfProcDumpEnabled() this.context); // Setup - this.mockProcessDumpUtility.Setup(x => x.GetDumpFiles()).Returns(new[] { this.filepath }); + this.mockProcessDumpUtility.Setup(x => x.GetDumpFiles(It.IsAny())).Returns(new[] { this.filepath }); this.mockBlameReaderWriter.Setup(x => x.WriteTestSequence(It.IsAny>(), It.IsAny>(), It.IsAny())) .Returns(this.filepath); @@ -376,7 +376,7 @@ public void TriggerSessionEndedHandlerShouldGetDumpFileIfProcDumpEnabled() this.mockDataColectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(this.dataCollectionContext)); // Verify GetDumpFiles Call - this.mockProcessDumpUtility.Verify(x => x.GetDumpFiles(), Times.Once); + this.mockProcessDumpUtility.Verify(x => x.GetDumpFiles(It.IsAny()), Times.Once); } /// @@ -418,7 +418,7 @@ public void TriggerSessionEndedHandlerShouldGetDumpFileIfCollectDumpOnExitIsEnab this.context); // Setup - this.mockProcessDumpUtility.Setup(x => x.GetDumpFiles()).Returns(new[] { this.filepath }); + this.mockProcessDumpUtility.Setup(x => x.GetDumpFiles(true)).Returns(new[] { this.filepath }); this.mockBlameReaderWriter.Setup(x => x.WriteTestSequence(It.IsAny>(), It.IsAny>(), It.IsAny())) .Returns(this.filepath); @@ -427,7 +427,7 @@ public void TriggerSessionEndedHandlerShouldGetDumpFileIfCollectDumpOnExitIsEnab this.mockDataColectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(this.dataCollectionContext)); // Verify GetDumpFiles Call - this.mockProcessDumpUtility.Verify(x => x.GetDumpFiles(), Times.Once); + this.mockProcessDumpUtility.Verify(x => x.GetDumpFiles(true), Times.Once); } /// @@ -437,8 +437,10 @@ public void TriggerSessionEndedHandlerShouldGetDumpFileIfCollectDumpOnExitIsEnab public void TriggerSessionEndedHandlerShouldLogWarningIfGetDumpFileThrowsFileNotFound() { // Initializing Blame Data Collector + // force it to collect dump on exit, which won't happen and we should see a warning + // but we should not see warning if we tell it to create dump and there is no crash this.blameDataCollector.Initialize( - this.GetDumpConfigurationElement(), + this.GetDumpConfigurationElement(false, collectDumpOnExit: true), this.mockDataColectionEvents.Object, this.mockDataCollectionSink.Object, this.mockLogger.Object, @@ -447,7 +449,7 @@ public void TriggerSessionEndedHandlerShouldLogWarningIfGetDumpFileThrowsFileNot // Setup and raise events this.mockBlameReaderWriter.Setup(x => x.WriteTestSequence(It.IsAny>(), It.IsAny>(), It.IsAny())) .Returns(this.filepath); - this.mockProcessDumpUtility.Setup(x => x.GetDumpFiles()).Throws(new FileNotFoundException()); + this.mockProcessDumpUtility.Setup(x => x.GetDumpFiles(true)).Throws(new FileNotFoundException()); this.mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(this.dataCollectionContext, 1234)); this.mockDataColectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(new TestCase())); this.mockDataColectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(this.dataCollectionContext)); @@ -605,6 +607,29 @@ public void TriggerTestHostLaunchedHandlerShouldLogWarningForNonBooleanCollectAl this.mockLogger.Verify(x => x.LogWarning(It.IsAny(), It.Is(str => str == string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterValueIncorrect, "DumpType", BlameDataCollector.Constants.FullConfigurationValue, BlameDataCollector.Constants.MiniConfigurationValue))), Times.Once); } + /// + /// The trigger test host launched handler should start process dump utility for full dump if full dump was enabled + /// + [TestMethod] + public void TriggerTestHostLaunchedHandlerShouldLogNoWarningWhenDumpTypeIsUsedWithHangDumpBecauseEitherHangDumpTypeOrDumpTypeCanBeSpecified() + { + var dumpConfig = this.GetDumpConfigurationElement(isFullDump: true, false, colectDumpOnHang: true, 1800000); + + // Initializing Blame Data Collector + this.blameDataCollector.Initialize( + dumpConfig, + this.mockDataColectionEvents.Object, + this.mockDataCollectionSink.Object, + this.mockLogger.Object, + this.context); + + // Raise TestHostLaunched + this.mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(this.dataCollectionContext, 1234)); + + // Verify + this.mockLogger.Verify(x => x.LogWarning(It.IsAny(), It.IsAny()), Times.Never); + } + /// /// The trigger test host launched handler should not break if start process dump throws TestPlatFormExceptions and log error message /// diff --git a/test/vstest.console.UnitTests/Processors/EnableBlameArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/EnableBlameArgumentProcessorTests.cs index a691cbe5dc..24566e7ab1 100644 --- a/test/vstest.console.UnitTests/Processors/EnableBlameArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/EnableBlameArgumentProcessorTests.cs @@ -25,7 +25,14 @@ public class EnableBlameArgumentProcessorTests private Mock mockOutput; private TestableRunSettingsProvider settingsProvider; private EnableBlameArgumentExecutor executor; - private const string DefaultRunSettings = "\r\n\r\n \r\n \r\n \r\n C:\\dir\\TestResults\r\n "; + private string DefaultRunSettings = string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " "); public EnableBlameArgumentProcessorTests() { @@ -78,7 +85,28 @@ public void InitializeShouldCreateEntryForBlameInRunSettingsIfNotAlreadyPresent( this.executor.Initialize(""); Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual("\r\n\r\n \r\n \r\n \r\n \r\n C:\\dir\\TestResults\r\n \r\n \r\n \r\n \r\n \r\n C:\\dir\\TestResults\r\n \r\n \r\n \r\n \r\n \r\n \r\n", this.settingsProvider.ActiveRunSettings.SettingsXml); + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " ", + "" + ), this.settingsProvider.ActiveRunSettings.SettingsXml); } [TestMethod] @@ -86,13 +114,56 @@ public void InitializeShouldOverwriteEntryForBlameInRunSettingsIfAlreadyPresent( { var runsettingsString = string.Format(DefaultRunSettings, ""); var runsettings = new RunSettings(); - runsettings.LoadSettingsXml("\r\n\r\n \r\n \r\n \r\n \r\n C:\\dir\\TestResults\r\n \r\n \r\n \r\n \r\n \r\n \r\n C:\\dir\\TestResults\r\n \r\n \r\n \r\n \r\n \r\n \r\n"); + runsettings.LoadSettingsXml(string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " ", + "")); this.settingsProvider.SetActiveRunSettings(runsettings); this.executor.Initialize("CollectDump;DumpType=full;CollectAlways=true"); Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual("\r\n\r\n \r\n \r\n \r\n \r\n C:\\dir\\TestResults\r\n \r\n \r\n \r\n \r\n \r\n \r\n C:\\dir\\TestResults\r\n \r\n \r\n \r\n \r\n \r\n \r\n", this.settingsProvider.ActiveRunSettings.SettingsXml); + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " ", + ""), + this.settingsProvider.ActiveRunSettings.SettingsXml); } [TestMethod] @@ -118,7 +189,28 @@ public void InitializeShouldWarnIfPlatformNotSupportedForCollectDumpOption() this.mockOutput.Verify(x => x.WriteLine(CommandLineResources.BlameCollectDumpNotSupportedForPlatform, OutputLevel.Warning)); Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual("\r\n\r\n \r\n \r\n \r\n \r\n C:\\dir\\TestResults\r\n \r\n \r\n \r\n \r\n \r\n C:\\dir\\TestResults\r\n \r\n \r\n \r\n \r\n \r\n \r\n", this.settingsProvider.ActiveRunSettings.SettingsXml); + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " ", + ""), + this.settingsProvider.ActiveRunSettings.SettingsXml); } } @@ -140,7 +232,28 @@ public void InitializeShouldWarnIfIncorrectParameterIsSpecifiedForCollectDumpOpt this.mockOutput.Verify(x => x.WriteLine(string.Format(CultureInfo.CurrentUICulture, CommandLineResources.BlameIncorrectOption, invalidParameter), OutputLevel.Warning)); Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual("\r\n\r\n \r\n \r\n \r\n \r\n C:\\dir\\TestResults\r\n \r\n \r\n \r\n \r\n \r\n C:\\dir\\TestResults\r\n \r\n \r\n \r\n \r\n \r\n \r\n", this.settingsProvider.ActiveRunSettings.SettingsXml); + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " ", + ""), + this.settingsProvider.ActiveRunSettings.SettingsXml); } [TestMethod] @@ -162,7 +275,28 @@ public void InitializeShouldThrowIfInvalidParameterFormatIsSpecifiedForCollectDu this.mockOutput.Verify(x => x.WriteLine(string.Format(CultureInfo.CurrentUICulture, CommandLineResources.InvalidBlameArgument, invalidString), OutputLevel.Warning)); Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual("\r\n\r\n \r\n \r\n \r\n \r\n C:\\dir\\TestResults\r\n \r\n \r\n \r\n \r\n \r\n C:\\dir\\TestResults\r\n \r\n \r\n \r\n \r\n \r\n \r\n", this.settingsProvider.ActiveRunSettings.SettingsXml); + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " ", + ""), + this.settingsProvider.ActiveRunSettings.SettingsXml); } [TestMethod] @@ -181,7 +315,29 @@ public void InitializeShouldCreateEntryForBlameAlongWithCollectDumpEntryIfEnable this.executor.Initialize("CollectDump"); Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual("\r\n\r\n \r\n \r\n \r\n \r\n C:\\dir\\TestResults\r\n \r\n \r\n \r\n \r\n \r\n \r\n C:\\dir\\TestResults\r\n \r\n \r\n \r\n \r\n \r\n \r\n", this.settingsProvider.ActiveRunSettings.SettingsXml); + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " ", + ""), + this.settingsProvider.ActiveRunSettings.SettingsXml); } [TestMethod] @@ -200,7 +356,29 @@ public void InitializeShouldCreateEntryForBlameAlongWithCollectDumpParametersIfE this.executor.Initialize("CollectDump;DumpType=full;CollectAlways=true"); Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual("\r\n\r\n \r\n \r\n \r\n \r\n C:\\dir\\TestResults\r\n \r\n \r\n \r\n \r\n \r\n \r\n C:\\dir\\TestResults\r\n \r\n \r\n \r\n \r\n \r\n \r\n", this.settingsProvider.ActiveRunSettings.SettingsXml); + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " ", + ""), + this.settingsProvider.ActiveRunSettings.SettingsXml); } [TestMethod] @@ -219,7 +397,71 @@ public void InitializeShouldCreateEntryForBlameAlongWithCollectHangDumpEntryIfEn this.executor.Initialize("CollectHangDump"); Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - Assert.AreEqual("\r\n\r\n \r\n \r\n \r\n \r\n C:\\dir\\TestResults\r\n \r\n \r\n \r\n \r\n \r\n \r\n C:\\dir\\TestResults\r\n \r\n \r\n \r\n \r\n \r\n \r\n", this.settingsProvider.ActiveRunSettings.SettingsXml); + Assert.AreEqual( + string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " ", + ""), + this.settingsProvider.ActiveRunSettings.SettingsXml); + } + + [TestMethod] + public void InitializeShouldCreateEntryForBlameAlongWithCollectHangDumpParametersIfEnabled() + { + var runsettingsString = string.Format(DefaultRunSettings, ""); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(DefaultRunSettings); + this.settingsProvider.SetActiveRunSettings(runsettings); + + this.mockEnvronment.Setup(x => x.OperatingSystem) + .Returns(PlatformOperatingSystem.Windows); + this.mockEnvronment.Setup(x => x.Architecture) + .Returns(PlatformArchitecture.X64); + + this.executor.Initialize("CollectHangDump;TestTimeout=10min;HangDumpType=Mini"); + + Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " ", + " C:\\dir\\TestResults", + " ", + " ", + " ", + " ", + " ", + " ", + ""), + this.settingsProvider.ActiveRunSettings.SettingsXml); } internal class TestableEnableBlameArgumentExecutor : EnableBlameArgumentExecutor