diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/SocketCommunicationManager.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/SocketCommunicationManager.cs index 093a19b7d2..bc9a5b0208 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/SocketCommunicationManager.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/SocketCommunicationManager.cs @@ -70,6 +70,11 @@ public class SocketCommunicationManager : ICommunicationManager /// private object sendSyncObject = new object(); + /// + /// Sync object for receiving messages + /// + private object receiveSyncObject = new object(); + private Socket socket; /// @@ -311,7 +316,11 @@ public async Task ReceiveMessageAsync(CancellationToken cancellationTok /// Raw message string public string ReceiveRawMessage() { - return this.binaryReader.ReadString(); + lock (this.receiveSyncObject) + { + // Reading message on binaryreader is not thread-safe + return this.binaryReader.ReadString(); + } } /// diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameCollector.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameCollector.cs index 9ac6ea5605..316d07317d 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameCollector.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameCollector.cs @@ -30,6 +30,8 @@ public class BlameCollector : DataCollector, ITestExecutionEnvironmentSpecifier private int testStartCount; private int testEndCount; private bool processDumpEnabled; + private bool collectDumpAlways; + private bool processFullDumpEnabled; private string attachmentGuid; /// @@ -97,12 +99,50 @@ public override void Initialize( if (this.configurationElement != null) { - this.processDumpEnabled = this.configurationElement[Constants.DumpModeKey] != null; + var collectDumpNode = this.configurationElement[Constants.DumpModeKey]; + this.processDumpEnabled = collectDumpNode != null; + if (this.processDumpEnabled) + { + this.ValidateAndAddProcessDumpParameters(collectDumpNode); + } } this.attachmentGuid = Guid.NewGuid().ToString().Replace("-", string.Empty); } + private void ValidateAndAddProcessDumpParameters(XmlElement collectDumpNode) + { + foreach (XmlAttribute attribute in collectDumpNode.Attributes) + { + if (string.Equals(attribute.Name, Constants.CollectDumpAlwaysKey, StringComparison.OrdinalIgnoreCase)) + { + if (string.Equals(attribute.Value, Constants.TrueConfigurationValue, StringComparison.OrdinalIgnoreCase) || string.Equals(attribute.Value, Constants.FalseConfigurationValue, StringComparison.OrdinalIgnoreCase)) + { + bool.TryParse(attribute.Value, out this.collectDumpAlways); + } + else + { + this.logger.LogWarning(this.context.SessionDataCollectionContext, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterValueIncorrect, attribute.Name, Constants.TrueConfigurationValue, Constants.FalseConfigurationValue)); + } + } + else if (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)); + } + } + else + { + this.logger.LogWarning(this.context.SessionDataCollectionContext, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterKeyIncorrect, attribute.Name)); + } + } + } + /// /// Called when Test Case Start event is invoked /// @@ -159,23 +199,29 @@ private void SessionEnded_Handler(object sender, SessionEndEventArgs args) if (this.processDumpEnabled) { - try + // If there was a test case crash or if we need to collect dump on process exit. + if (this.testStartCount > this.testEndCount || this.collectDumpAlways) { - var dumpFile = this.processDumpUtility.GetDumpFile(); - if (!string.IsNullOrEmpty(dumpFile)) + try { - var fileTranferInformation = new FileTransferInformation(this.context.SessionDataCollectionContext, dumpFile, true); - this.dataCollectionSink.SendFileAsync(fileTranferInformation); + var dumpFile = this.processDumpUtility.GetDumpFile(); + if (!string.IsNullOrEmpty(dumpFile)) + { + var fileTranferInformation = new FileTransferInformation(this.context.SessionDataCollectionContext, dumpFile, true); + this.dataCollectionSink.SendFileAsync(fileTranferInformation); + } + else + { + EqtTrace.Warning("BlameCollector.SessionEnded_Handler: blame:CollectDump was enabled but dump file was not generated."); + this.logger.LogWarning(args.Context, Resources.Resources.ProcDumpNotGenerated); + } } - else + catch (FileNotFoundException ex) { - EqtTrace.Warning("BlameCollector.SessionEnded_Handler: blame:CollectDump was enabled but dump file was not generated."); + EqtTrace.Warning(ex.Message); + this.logger.LogWarning(args.Context, ex.Message); } } - catch (FileNotFoundException ex) - { - this.logger.LogWarning(args.Context, ex.Message); - } } this.DeregisterEvents(); @@ -195,7 +241,7 @@ private void TestHostLaunched_Handler(object sender, TestHostLaunchedEventArgs a try { - this.processDumpUtility.StartProcessDump(args.TestHostProcessId, this.attachmentGuid, this.GetResultsDirectory()); + this.processDumpUtility.StartProcessDump(args.TestHostProcessId, this.attachmentGuid, this.GetResultsDirectory(), this.processFullDumpEnabled); } catch (TestPlatformException e) { @@ -204,7 +250,7 @@ private void TestHostLaunched_Handler(object sender, TestHostLaunchedEventArgs a EqtTrace.Warning("BlameCollector.TestHostLaunched_Handler: Could not start process dump. {0}", e); } - this.logger.LogWarning(args.Context, e.Message); + this.logger.LogWarning(args.Context, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.ProcDumpCouldNotStart, e.Message)); } catch (Exception e) { @@ -213,7 +259,7 @@ private void TestHostLaunched_Handler(object sender, TestHostLaunchedEventArgs a EqtTrace.Warning("BlameCollector.TestHostLaunched_Handler: Could not start process dump. {0}", e); } - this.logger.LogWarning(args.Context, e.ToString()); + this.logger.LogWarning(args.Context, string.Format(CultureInfo.CurrentUICulture, Resources.Resources.ProcDumpCouldNotStart, e.ToString())); } } diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Constants.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Constants.cs index f060ab8a0a..a69e025599 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Constants.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Constants.cs @@ -42,5 +42,35 @@ internal static class Constants /// Configuration key name for dump mode /// public const string DumpModeKey = "CollectDump"; + + /// + /// Configuration key name for collect dump always + /// + public const string CollectDumpAlwaysKey = "CollectAlways"; + + /// + /// Configuration key name for dump type + /// + public const string DumpTypeKey = "DumpType"; + + /// + /// Configuration value for true + /// + public const string TrueConfigurationValue = "True"; + + /// + /// Configuration value for false + /// + public const string FalseConfigurationValue = "False"; + + /// + /// Configuration value for full + /// + public const string FullConfigurationValue = "Full"; + + /// + /// Configuration value for mini + /// + public const string MiniConfigurationValue = "Mini"; } } diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IProcessDumpUtility.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IProcessDumpUtility.cs index 7240edd688..5aff12e962 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IProcessDumpUtility.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Interfaces/IProcessDumpUtility.cs @@ -27,6 +27,9 @@ public interface IProcessDumpUtility /// /// Path to TestResults directory /// - void StartProcessDump(int processId, string dumpFileGuid, string testResultsDirectory); + /// + /// Is full dump enabled + /// + void StartProcessDump(int processId, string dumpFileGuid, string testResultsDirectory, bool isFullDump = false); } } diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessDumpUtility.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessDumpUtility.cs index 34388a84b1..56ef19d6d4 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessDumpUtility.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessDumpUtility.cs @@ -71,14 +71,14 @@ public string GetDumpFile() } /// - public void StartProcessDump(int processId, string dumpFileGuid, string testResultsDirectory) + public void StartProcessDump(int processId, string dumpFileGuid, string testResultsDirectory, bool isFullDump = false) { this.dumpFileName = $"{this.processHelper.GetProcessName(processId)}_{processId}_{dumpFileGuid}"; this.testResultsDirectory = testResultsDirectory; this.procDumpProcess = this.processHelper.LaunchProcess( this.GetProcDumpExecutable(), - ProcessDumpUtility.BuildProcDumpArgs(processId, this.dumpFileName), + ProcessDumpUtility.BuildProcDumpArgs(processId, this.dumpFileName, isFullDump), testResultsDirectory, null, null, @@ -94,13 +94,24 @@ public void StartProcessDump(int processId, string dumpFileGuid, string testResu /// /// Filename for dump file /// + /// + /// Is full dump enabled + /// /// Arguments - private static string BuildProcDumpArgs(int processId, string filename) + private static string BuildProcDumpArgs(int processId, string filename, bool isFullDump = false) { // -accepteula: Auto accept end-user license agreement // -t: Write a dump when the process terminates. - // This will create a minidump of the process with specified filename - return "-accepteula -t " + processId + " " + filename + ".dmp"; + if (isFullDump) + { + // This will create a fulldump of the process with specified filename + return "-accepteula -t -ma " + processId + " " + filename + ".dmp"; + } + else + { + // This will create a minidump of the process with specified filename + return "-accepteula -t " + processId + " " + filename + ".dmp"; + } } /// diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/Resources.Designer.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/Resources.Designer.cs index d62173d17d..959f718ca8 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/Resources.Designer.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/Resources.Designer.cs @@ -69,6 +69,39 @@ internal static string AbortedTestRun { } } + /// + /// The blame parameter key specified {0} is not valid. Ignoring this key.. + /// + internal static string BlameParameterKeyIncorrect + { + get + { + return ResourceManager.GetString("BlameParameterKeyIncorrect", resourceCulture); + } + } + + /// + /// The blame parameter key {0} can only support values {1}/{2}. Ignoring this key.. + /// + internal static string BlameParameterValueIncorrect + { + get + { + return ResourceManager.GetString("BlameParameterValueIncorrect", resourceCulture); + } + } + + /// + /// Could not start process dump: {0}. + /// + internal static string ProcDumpCouldNotStart + { + get + { + return ResourceManager.GetString("ProcDumpCouldNotStart", resourceCulture); + } + } + /// /// Looks up a localized string similar to Required environment variable PROCDUMP_PATH was null or empty. Set PROCDUMP_PATH to path of folder containing appropriate procdump executable. /// @@ -80,6 +113,17 @@ internal static string ProcDumpEnvVarEmpty } } + /// + /// CollectDump was enabled but dump file was not generated.. + /// + internal static string ProcDumpNotGenerated + { + get + { + return ResourceManager.GetString("ProcDumpNotGenerated", resourceCulture); + } + } + /// /// Looks up a localized string similar to Collect dump was enabled but no dump file was generated. /// diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/Resources.resx b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/Resources.resx index 8264dc43a3..1106193219 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/Resources.resx +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/Resources.resx @@ -120,10 +120,22 @@ The active Test Run was aborted because the host process exited unexpectedly while executing following test(s): + + The blame parameter key specified {0} is not valid. Ignoring this key. + + + The blame parameter key {0} can only support values {1}/{2}. Ignoring this key. + Collect dump was enabled but no dump file was generated. + + Could not start process dump: {0} + Required environment variable PROCDUMP_PATH was null or empty. Set PROCDUMP_PATH to path of folder containing appropriate procdump executable. + + CollectDump was enabled but dump file was not generated. + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.cs.xlf b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.cs.xlf index 3d9d7d20e5..940447921f 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.cs.xlf +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.cs.xlf @@ -35,6 +35,26 @@ Bylo povoleno shromáždění výpisu, ale nebyl vygenerován žádný soubor výpisu. + + The blame parameter key specified {0} is not valid. Ignoring this key. + The blame parameter key {0} is not valid. Ignoring this parameter. + + + + The blame parameter key {0} can only support values {1}/{2}. Ignoring this key. + The blame parameter key {0} can only support values {1}/{2}. Ignoring this parameter. + + + + Could not start process dump: {0} + Could not start process dump: {0} + + + + CollectDump was enabled but dump file was not generated. + CollectDump was enabled but dump file was not generated. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.de.xlf b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.de.xlf index 1f640ac6db..26872ed16c 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.de.xlf +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.de.xlf @@ -35,6 +35,26 @@ Die Abbilderfassung war aktiviert, aber es wurde keine Abbilddatei generiert. + + The blame parameter key specified {0} is not valid. Ignoring this key. + The blame parameter key {0} is not valid. Ignoring this parameter. + + + + The blame parameter key {0} can only support values {1}/{2}. Ignoring this key. + The blame parameter key {0} can only support values {1}/{2}. Ignoring this parameter. + + + + Could not start process dump: {0} + Could not start process dump: {0} + + + + CollectDump was enabled but dump file was not generated. + CollectDump was enabled but dump file was not generated. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.es.xlf b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.es.xlf index 0c14c801b0..43e794307a 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.es.xlf +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.es.xlf @@ -35,6 +35,26 @@ La opción para recopilar un volcado de memoria estaba habilitada, pero no se generó ningún archivo de volcado de memoria. + + The blame parameter key specified {0} is not valid. Ignoring this key. + The blame parameter key {0} is not valid. Ignoring this parameter. + + + + The blame parameter key {0} can only support values {1}/{2}. Ignoring this key. + The blame parameter key {0} can only support values {1}/{2}. Ignoring this parameter. + + + + Could not start process dump: {0} + Could not start process dump: {0} + + + + CollectDump was enabled but dump file was not generated. + CollectDump was enabled but dump file was not generated. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.fr.xlf b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.fr.xlf index 59467f7b37..dd1cfe8bba 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.fr.xlf +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.fr.xlf @@ -35,6 +35,26 @@ La collecte de fichiers dump a été activée, mais aucun fichier dump n'a été généré. + + The blame parameter key specified {0} is not valid. Ignoring this key. + The blame parameter key {0} is not valid. Ignoring this parameter. + + + + The blame parameter key {0} can only support values {1}/{2}. Ignoring this key. + The blame parameter key {0} can only support values {1}/{2}. Ignoring this parameter. + + + + Could not start process dump: {0} + Could not start process dump: {0} + + + + CollectDump was enabled but dump file was not generated. + CollectDump was enabled but dump file was not generated. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.it.xlf b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.it.xlf index 035c47388f..cbac6c395d 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.it.xlf +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.it.xlf @@ -35,6 +35,26 @@ La raccolta del dump è stata abilitata ma non è stato generato alcun file di dump. + + The blame parameter key specified {0} is not valid. Ignoring this key. + The blame parameter key {0} is not valid. Ignoring this parameter. + + + + The blame parameter key {0} can only support values {1}/{2}. Ignoring this key. + The blame parameter key {0} can only support values {1}/{2}. Ignoring this parameter. + + + + Could not start process dump: {0} + Could not start process dump: {0} + + + + CollectDump was enabled but dump file was not generated. + CollectDump was enabled but dump file was not generated. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.ja.xlf b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.ja.xlf index 5cf170ba4a..840b5fe352 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.ja.xlf +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.ja.xlf @@ -35,6 +35,26 @@ ダンプの収集は有効化されましたが、ダンプ ファイルは生成されませんでした。 + + The blame parameter key specified {0} is not valid. Ignoring this key. + The blame parameter key {0} is not valid. Ignoring this parameter. + + + + The blame parameter key {0} can only support values {1}/{2}. Ignoring this key. + The blame parameter key {0} can only support values {1}/{2}. Ignoring this parameter. + + + + Could not start process dump: {0} + Could not start process dump: {0} + + + + CollectDump was enabled but dump file was not generated. + CollectDump was enabled but dump file was not generated. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.ko.xlf b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.ko.xlf index ffcd88fcb3..56ad96a37f 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.ko.xlf +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.ko.xlf @@ -35,6 +35,26 @@ 덤프 수집이 사용하도록 설정되었지만 덤프 파일이 생성되지 않았습니다. + + The blame parameter key specified {0} is not valid. Ignoring this key. + The blame parameter key {0} is not valid. Ignoring this parameter. + + + + The blame parameter key {0} can only support values {1}/{2}. Ignoring this key. + The blame parameter key {0} can only support values {1}/{2}. Ignoring this parameter. + + + + Could not start process dump: {0} + Could not start process dump: {0} + + + + CollectDump was enabled but dump file was not generated. + CollectDump was enabled but dump file was not generated. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.pl.xlf b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.pl.xlf index de02fc0f93..49fdb137c9 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.pl.xlf +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.pl.xlf @@ -35,6 +35,26 @@ Zbieranie zrzutów zostało włączone, ale nie wygenerowano żadnego pliku zrzutu. + + The blame parameter key specified {0} is not valid. Ignoring this key. + The blame parameter key {0} is not valid. Ignoring this parameter. + + + + The blame parameter key {0} can only support values {1}/{2}. Ignoring this key. + The blame parameter key {0} can only support values {1}/{2}. Ignoring this parameter. + + + + Could not start process dump: {0} + Could not start process dump: {0} + + + + CollectDump was enabled but dump file was not generated. + CollectDump was enabled but dump file was not generated. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.pt-BR.xlf b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.pt-BR.xlf index f6ab620fc9..e6c87dd25c 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.pt-BR.xlf +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.pt-BR.xlf @@ -35,6 +35,26 @@ A coleta de despejo estava habilitada, mas não foi gerado nenhum arquivo de despejo. + + The blame parameter key specified {0} is not valid. Ignoring this key. + The blame parameter key {0} is not valid. Ignoring this parameter. + + + + The blame parameter key {0} can only support values {1}/{2}. Ignoring this key. + The blame parameter key {0} can only support values {1}/{2}. Ignoring this parameter. + + + + Could not start process dump: {0} + Could not start process dump: {0} + + + + CollectDump was enabled but dump file was not generated. + CollectDump was enabled but dump file was not generated. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.ru.xlf b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.ru.xlf index 055fa926b6..7f1e29681b 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.ru.xlf +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.ru.xlf @@ -35,6 +35,26 @@ Сбор дампа включен, но файл дампа не создан. + + The blame parameter key specified {0} is not valid. Ignoring this key. + The blame parameter key {0} is not valid. Ignoring this parameter. + + + + The blame parameter key {0} can only support values {1}/{2}. Ignoring this key. + The blame parameter key {0} can only support values {1}/{2}. Ignoring this parameter. + + + + Could not start process dump: {0} + Could not start process dump: {0} + + + + CollectDump was enabled but dump file was not generated. + CollectDump was enabled but dump file was not generated. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.tr.xlf b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.tr.xlf index cb2b5578d8..3ec68b1602 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.tr.xlf +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.tr.xlf @@ -35,6 +35,26 @@ Döküm toplama etkindi, ancak hiçbir döküm dosyası oluşturulmamıştı. + + The blame parameter key specified {0} is not valid. Ignoring this key. + The blame parameter key {0} is not valid. Ignoring this parameter. + + + + The blame parameter key {0} can only support values {1}/{2}. Ignoring this key. + The blame parameter key {0} can only support values {1}/{2}. Ignoring this parameter. + + + + Could not start process dump: {0} + Could not start process dump: {0} + + + + CollectDump was enabled but dump file was not generated. + CollectDump was enabled but dump file was not generated. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.xlf b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.xlf index d72978ec30..43ecfc18ff 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.xlf +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.xlf @@ -17,6 +17,26 @@ Collect dump was enabled but no dump file was generated. + + The blame parameter key specified {0} is not valid. Ignoring this key. + The blame parameter key {0} is not valid. Ignoring this parameter. + + + + The blame parameter key {0} can only support values {1}/{2}. Ignoring this key. + The blame parameter key {0} can only support values {1}/{2}. Ignoring this parameter. + + + + Could not start process dump: {0} + Could not start process dump: {0} + + + + CollectDump was enabled but dump file was not generated. + CollectDump was enabled but dump file was not generated. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.zh-Hans.xlf b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.zh-Hans.xlf index 07a2a93293..a2afff0535 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.zh-Hans.xlf @@ -35,6 +35,26 @@ 收集转储已启用,但是未生成转储文件。 + + The blame parameter key specified {0} is not valid. Ignoring this key. + The blame parameter key {0} is not valid. Ignoring this parameter. + + + + The blame parameter key {0} can only support values {1}/{2}. Ignoring this key. + The blame parameter key {0} can only support values {1}/{2}. Ignoring this parameter. + + + + Could not start process dump: {0} + Could not start process dump: {0} + + + + CollectDump was enabled but dump file was not generated. + CollectDump was enabled but dump file was not generated. + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.zh-Hant.xlf b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.zh-Hant.xlf index e6e2e68611..a7cb6749a4 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Resources/xlf/Resources.zh-Hant.xlf @@ -35,6 +35,26 @@ 已啟用了收集傾印,但未產生任何傾印檔。 + + The blame parameter key specified {0} is not valid. Ignoring this key. + The blame parameter key {0} is not valid. Ignoring this parameter. + + + + The blame parameter key {0} can only support values {1}/{2}. Ignoring this key. + The blame parameter key {0} can only support values {1}/{2}. Ignoring this parameter. + + + + Could not start process dump: {0} + Could not start process dump: {0} + + + + CollectDump was enabled but dump file was not generated. + CollectDump was enabled but dump file was not generated. + + \ No newline at end of file diff --git a/src/vstest.console/Processors/EnableBlameArgumentProcessor.cs b/src/vstest.console/Processors/EnableBlameArgumentProcessor.cs index 32a42ad4e3..4ac5180800 100644 --- a/src/vstest.console/Processors/EnableBlameArgumentProcessor.cs +++ b/src/vstest.console/Processors/EnableBlameArgumentProcessor.cs @@ -4,18 +4,22 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors { using System; + using System.Collections.Generic; + using System.Globalization; using System.Xml; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; + using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; using Microsoft.VisualStudio.TestPlatform.Common; using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; using Microsoft.VisualStudio.TestPlatform.Common.Utilities; using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; using Microsoft.VisualStudio.TestPlatform.Utilities; + using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; + internal class EnableBlameArgumentProcessor : IArgumentProcessor { /// @@ -30,7 +34,7 @@ internal class EnableBlameArgumentProcessor : IArgumentProcessor /// /// Initializes a new instance of the class. /// - public EnableBlameArgumentProcessor() + public EnableBlameArgumentProcessor() { } @@ -133,7 +137,14 @@ public void Initialize(string argument) { bool isDumpEnabled = false; - if (!string.IsNullOrWhiteSpace(argument) && argument.Equals(Constants.BlameCollectDumpKey, StringComparison.OrdinalIgnoreCase)) + var parseSucceeded = LoggerUtilities.TryParseLoggerArgument(argument, out string loggerIdentifier, out Dictionary parameters); + + if (!string.IsNullOrWhiteSpace(argument) && !parseSucceeded) + { + throw new CommandLineException(string.Format(CultureInfo.CurrentUICulture, CommandLineResources.BlameInvalidFormat, argument)); + } + + if (loggerIdentifier != null && loggerIdentifier.Equals(Constants.BlameCollectDumpKey, StringComparison.OrdinalIgnoreCase)) { if (this.environment.OperatingSystem == PlatformOperatingSystem.Windows && this.environment.Architecture != PlatformArchitecture.ARM64 && @@ -146,6 +157,10 @@ public void Initialize(string argument) Output.Warning(false, CommandLineResources.BlameCollectDumpNotSupportedForPlatform); } } + else + { + Output.Warning(false, string.Format(CultureInfo.CurrentUICulture, CommandLineResources.BlameIncorrectOption, loggerIdentifier)); + } // Add Blame Logger EnableLoggerArgumentExecutor.AddLoggerToRunSettings(BlameFriendlyName, this.runSettingsManager); @@ -194,13 +209,12 @@ public void Initialize(string argument) if (isDumpEnabled) { - var dumpNode = XmlDocument.CreateElement(Constants.BlameCollectDumpKey); - outernode.AppendChild(dumpNode); + AddCollectDumpNode(parameters, XmlDocument, outernode); } foreach (var item in dataCollectionRunSettings.DataCollectorSettingsList) { - if( item.FriendlyName.Equals(BlameFriendlyName)) + if (item.FriendlyName.Equals(BlameFriendlyName)) { item.Configuration = outernode; } @@ -209,6 +223,21 @@ public void Initialize(string argument) runSettingsManager.UpdateRunSettingsNodeInnerXml(Constants.DataCollectionRunSettingsName, dataCollectionRunSettings.ToXml().InnerXml); } + private void AddCollectDumpNode(Dictionary parameters, XmlDocument XmlDocument, XmlElement outernode) + { + var dumpNode = XmlDocument.CreateElement(Constants.BlameCollectDumpKey); + if (parameters != null && parameters.Count > 0) + { + foreach (KeyValuePair entry in parameters) + { + var attribute = XmlDocument.CreateAttribute(entry.Key); + attribute.Value = entry.Value; + dumpNode.Attributes.Append(attribute); + } + } + outernode.AppendChild(dumpNode); + } + /// /// Executes the argument processor. /// diff --git a/src/vstest.console/Resources/Resources.Designer.cs b/src/vstest.console/Resources/Resources.Designer.cs index 6043c954e7..72469be8e8 100644 --- a/src/vstest.console/Resources/Resources.Designer.cs +++ b/src/vstest.console/Resources/Resources.Designer.cs @@ -235,6 +235,28 @@ public static string BlameCollectDumpNotSupportedForPlatform } } + /// + /// The blame parameter specified with blame, {0} is invalid. Ignoring this parameter.. + /// + public static string BlameIncorrectOption + { + get + { + return ResourceManager.GetString("BlameIncorrectOption", resourceCulture); + } + } + + /// + /// The blame option specified '{0}' is not a valid format. Please correct it and retry.. + /// + public static string BlameInvalidFormat + { + get + { + return ResourceManager.GetString("BlameInvalidFormat", resourceCulture); + } + } + /// /// Looks up a localized string similar to --BuildBasePath|/BuildBasePath:<BuildBasePath> /// The directory containing the temporary outputs.. diff --git a/src/vstest.console/Resources/Resources.resx b/src/vstest.console/Resources/Resources.resx index b0474546c0..4d1bd137df 100644 --- a/src/vstest.console/Resources/Resources.resx +++ b/src/vstest.console/Resources/Resources.resx @@ -647,8 +647,18 @@ Read response file for more options. - --Blame|/Blame - Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. It creates an output file in the current directory as "Sequence.xml", that captures the order of execution of test before the crash. + --Blame|/Blame:[CollectDump];[CollectAlways]=[Value];[DumpType]=[Value] + Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. + It creates an output file in the current directory as "Sequence.xml", + that captures the order of execution of test before the crash. + You may optionally choose to collect process dump for the test host. + When you choose to collect dump, by default, a mini dump will be collected on a crash. + You may also choose to override this default behaviour by some optional parameters: + CollectAlways - To collect dump on exit even if there is no crash (true/false) + DumpType - To specify dump type (mini/full). + Example: /Blame + /Blame:CollectDump + /Blame:CollectDump;CollectAlways=true;DumpType=full Test Run Aborted. @@ -686,4 +696,10 @@ Example: /logger:console;prefix=<Defaults to "false"> More info on Console Logger here : https://aka.ms/console-logger + + The blame parameter specified with blame, {0} is invalid. Ignoring this parameter. + + + The blame option specified '{0}' is not a valid format. Please correct it and retry. + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.cs.xlf b/src/vstest.console/Resources/xlf/Resources.cs.xlf index 7e0b81b9d4..32bdf20b24 100644 --- a/src/vstest.console/Resources/xlf/Resources.cs.xlf +++ b/src/vstest.console/Resources/xlf/Resources.cs.xlf @@ -1482,11 +1482,21 @@ - --Blame|/Blame - Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. It creates an output file in the current directory as "Sequence.xml", that captures the order of execution of test before the crash. - --Blame|/Blame + --Blame|/Blame:[CollectDump];[CollectAlways]=[Value];[DumpType]=[Value] + Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. + It creates an output file in the current directory as "Sequence.xml", + that captures the order of execution of test before the crash. + You may optionally choose to collect process dump for the test host. + When you choose to collect dump, by default, a mini dump will be collected on a crash. + You may also choose to override this default behaviour by some optional parameters: + CollectAlways - To collect dump on exit even if there is no crash (true/false) + DumpType - To specify dump type (mini/full). + Example: /Blame + /Blame:CollectDump + /Blame:CollectDump;CollectAlways=true;DumpType=full + --Blame|/Blame Spustí test v režimu blame. Tato možnost je užitečná pro izolování problematického testu, který způsobuje chybové ukončení hostitele testů. V aktuálním adresáři se vytvoří výstupní soubor Sequence.xml, do kterého se zaznamená pořadí provádění testů před chybovým ukončením. - + Test Run Aborted. @@ -1579,6 +1589,16 @@ Možnost CollectDump pro Blame není pro tuto platformu podporovaná. + + The blame option specified '{0}' is not a valid format. Please correct it and retry. + The blame option specified '{0}' is not valid. This will be ignored. + + + + The blame parameter specified with blame, {0} is invalid. Ignoring this parameter. + The option specified with blame, {0} is invalid. This will be ignored. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.de.xlf b/src/vstest.console/Resources/xlf/Resources.de.xlf index 5552a47b5f..a5422091cc 100644 --- a/src/vstest.console/Resources/xlf/Resources.de.xlf +++ b/src/vstest.console/Resources/xlf/Resources.de.xlf @@ -1482,11 +1482,21 @@ - --Blame|/Blame - Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. It creates an output file in the current directory as "Sequence.xml", that captures the order of execution of test before the crash. - --Blame|/Blame + --Blame|/Blame:[CollectDump];[CollectAlways]=[Value];[DumpType]=[Value] + Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. + It creates an output file in the current directory as "Sequence.xml", + that captures the order of execution of test before the crash. + You may optionally choose to collect process dump for the test host. + When you choose to collect dump, by default, a mini dump will be collected on a crash. + You may also choose to override this default behaviour by some optional parameters: + CollectAlways - To collect dump on exit even if there is no crash (true/false) + DumpType - To specify dump type (mini/full). + Example: /Blame + /Blame:CollectDump + /Blame:CollectDump;CollectAlways=true;DumpType=full + --Blame|/Blame Führt den Test im Modus "Verantwortung zuweisen" aus. Diese Option hilft bei der Isolierung des problematischen Tests, der den Absturz des Testhosts verursacht. Im aktuellen Verzeichnis wird eine Ausgabedatei "Sequence.xml" erstellt, in der die Reihenfolge der Testausführung vor dem Absturz erfasst wird. - + Test Run Aborted. @@ -1579,6 +1589,16 @@ Die CollectDump-Option für Blame wird für diese Plattform nicht unterstützt. + + The blame option specified '{0}' is not a valid format. Please correct it and retry. + The blame option specified '{0}' is not valid. This will be ignored. + + + + The blame parameter specified with blame, {0} is invalid. Ignoring this parameter. + The option specified with blame, {0} is invalid. This will be ignored. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.es.xlf b/src/vstest.console/Resources/xlf/Resources.es.xlf index cff5994979..1c54f9f1df 100644 --- a/src/vstest.console/Resources/xlf/Resources.es.xlf +++ b/src/vstest.console/Resources/xlf/Resources.es.xlf @@ -1487,11 +1487,21 @@ - --Blame|/Blame - Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. It creates an output file in the current directory as "Sequence.xml", that captures the order of execution of test before the crash. - --Blame|/Blame + --Blame|/Blame:[CollectDump];[CollectAlways]=[Value];[DumpType]=[Value] + Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. + It creates an output file in the current directory as "Sequence.xml", + that captures the order of execution of test before the crash. + You may optionally choose to collect process dump for the test host. + When you choose to collect dump, by default, a mini dump will be collected on a crash. + You may also choose to override this default behaviour by some optional parameters: + CollectAlways - To collect dump on exit even if there is no crash (true/false) + DumpType - To specify dump type (mini/full). + Example: /Blame + /Blame:CollectDump + /Blame:CollectDump;CollectAlways=true;DumpType=full + --Blame|/Blame Ejecuta la prueba en modo de culpa. Esta opción es útil para aislar la prueba problemática que provoca el bloqueo del host de prueba. Crea un archivo de salida en el directorio actual como "Sequence.xml" que captura el orden de ejecución de la prueba antes del bloqueo. - + Test Run Aborted. @@ -1584,6 +1594,16 @@ No se admite la opción CollectDump para Blame en esta plataforma. + + The blame option specified '{0}' is not a valid format. Please correct it and retry. + The blame option specified '{0}' is not valid. This will be ignored. + + + + The blame parameter specified with blame, {0} is invalid. Ignoring this parameter. + The option specified with blame, {0} is invalid. This will be ignored. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.fr.xlf b/src/vstest.console/Resources/xlf/Resources.fr.xlf index bdc627129e..3fd78458eb 100644 --- a/src/vstest.console/Resources/xlf/Resources.fr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.fr.xlf @@ -1482,11 +1482,21 @@ - --Blame|/Blame - Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. It creates an output file in the current directory as "Sequence.xml", that captures the order of execution of test before the crash. - --Blame|/Blame + --Blame|/Blame:[CollectDump];[CollectAlways]=[Value];[DumpType]=[Value] + Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. + It creates an output file in the current directory as "Sequence.xml", + that captures the order of execution of test before the crash. + You may optionally choose to collect process dump for the test host. + When you choose to collect dump, by default, a mini dump will be collected on a crash. + You may also choose to override this default behaviour by some optional parameters: + CollectAlways - To collect dump on exit even if there is no crash (true/false) + DumpType - To specify dump type (mini/full). + Example: /Blame + /Blame:CollectDump + /Blame:CollectDump;CollectAlways=true;DumpType=full + --Blame|/Blame Exécute le test en mode blame (responsabilité). Cette option permet d'isoler le test problématique qui est à l'origine d'un incident sur l'hôte de test. Elle crée dans le répertoire actif un fichier de sortie nommé "Sequence.xml", qui capture l'ordre d'exécution du test avant l'incident. - + Test Run Aborted. @@ -1579,6 +1589,16 @@ L'option CollectDump pour Blame n'est pas prise en charge pour cette plateforme. + + The blame option specified '{0}' is not a valid format. Please correct it and retry. + The blame option specified '{0}' is not valid. This will be ignored. + + + + The blame parameter specified with blame, {0} is invalid. Ignoring this parameter. + The option specified with blame, {0} is invalid. This will be ignored. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.it.xlf b/src/vstest.console/Resources/xlf/Resources.it.xlf index 4564266cbf..e9a327c784 100644 --- a/src/vstest.console/Resources/xlf/Resources.it.xlf +++ b/src/vstest.console/Resources/xlf/Resources.it.xlf @@ -1482,11 +1482,21 @@ - --Blame|/Blame - Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. It creates an output file in the current directory as "Sequence.xml", that captures the order of execution of test before the crash. - --Blame|/Blame + --Blame|/Blame:[CollectDump];[CollectAlways]=[Value];[DumpType]=[Value] + Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. + It creates an output file in the current directory as "Sequence.xml", + that captures the order of execution of test before the crash. + You may optionally choose to collect process dump for the test host. + When you choose to collect dump, by default, a mini dump will be collected on a crash. + You may also choose to override this default behaviour by some optional parameters: + CollectAlways - To collect dump on exit even if there is no crash (true/false) + DumpType - To specify dump type (mini/full). + Example: /Blame + /Blame:CollectDump + /Blame:CollectDump;CollectAlways=true;DumpType=full + --Blame|/Blame Esegue il test in modalità di segnalazione errore. Questa opzione è utile per isolare il test problematico che causa l'arresto anomalo dell'host dei test. Crea nella directory corrente un file di output denominato "Sequence.xml", in cui viene acquisito l'ordine di esecuzione del test prima dell'arresto anomalo. - + Test Run Aborted. @@ -1579,6 +1589,16 @@ L'opzione CollectDump per Blame non è supportata per questa piattaforma. + + The blame option specified '{0}' is not a valid format. Please correct it and retry. + The blame option specified '{0}' is not valid. This will be ignored. + + + + The blame parameter specified with blame, {0} is invalid. Ignoring this parameter. + The option specified with blame, {0} is invalid. This will be ignored. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.ja.xlf b/src/vstest.console/Resources/xlf/Resources.ja.xlf index 003034bcc9..02df7b95f9 100644 --- a/src/vstest.console/Resources/xlf/Resources.ja.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ja.xlf @@ -1482,11 +1482,21 @@ - --Blame|/Blame - Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. It creates an output file in the current directory as "Sequence.xml", that captures the order of execution of test before the crash. - --Blame|/Blame + --Blame|/Blame:[CollectDump];[CollectAlways]=[Value];[DumpType]=[Value] + Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. + It creates an output file in the current directory as "Sequence.xml", + that captures the order of execution of test before the crash. + You may optionally choose to collect process dump for the test host. + When you choose to collect dump, by default, a mini dump will be collected on a crash. + You may also choose to override this default behaviour by some optional parameters: + CollectAlways - To collect dump on exit even if there is no crash (true/false) + DumpType - To specify dump type (mini/full). + Example: /Blame + /Blame:CollectDump + /Blame:CollectDump;CollectAlways=true;DumpType=full + --Blame|/Blame 変更履歴モードでテストを実行します。このオプションは、テスト ホストのクラッシュの原因となる問題のあるテストを分離する場合に役立ちます。現在のディレクトリに、クラッシュする前のテスト実行順序を示す出力ファイル "Sequence.xml" が作成されます。 - + Test Run Aborted. @@ -1579,6 +1589,16 @@ このプラットフォームでは、Blame の CollectDump オプションはサポートされていません。 + + The blame option specified '{0}' is not a valid format. Please correct it and retry. + The blame option specified '{0}' is not valid. This will be ignored. + + + + The blame parameter specified with blame, {0} is invalid. Ignoring this parameter. + The option specified with blame, {0} is invalid. This will be ignored. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.ko.xlf b/src/vstest.console/Resources/xlf/Resources.ko.xlf index 0a8462e503..f857f80db3 100644 --- a/src/vstest.console/Resources/xlf/Resources.ko.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ko.xlf @@ -1482,11 +1482,21 @@ - --Blame|/Blame - Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. It creates an output file in the current directory as "Sequence.xml", that captures the order of execution of test before the crash. - --Blame|/Blame + --Blame|/Blame:[CollectDump];[CollectAlways]=[Value];[DumpType]=[Value] + Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. + It creates an output file in the current directory as "Sequence.xml", + that captures the order of execution of test before the crash. + You may optionally choose to collect process dump for the test host. + When you choose to collect dump, by default, a mini dump will be collected on a crash. + You may also choose to override this default behaviour by some optional parameters: + CollectAlways - To collect dump on exit even if there is no crash (true/false) + DumpType - To specify dump type (mini/full). + Example: /Blame + /Blame:CollectDump + /Blame:CollectDump;CollectAlways=true;DumpType=full + --Blame|/Blame 테스트를 원인 모드로 실행합니다. 이 옵션은 테스트 호스트 작동을 중단시키는 문제 있는 테스트를 격리하는 데 유용합니다. 이 경우 현재 디렉터리에 "Sequence.xml"이라는 출력 파일을 만들며, 이 파일에는 작동 중단 이전 테스트 실행 순서가 캡처되어 있습니다. - + Test Run Aborted. @@ -1579,6 +1589,16 @@ Blame에 대한 CollectDump 옵션이 이 플랫폼에서 지원되지 않습니다. + + The blame option specified '{0}' is not a valid format. Please correct it and retry. + The blame option specified '{0}' is not valid. This will be ignored. + + + + The blame parameter specified with blame, {0} is invalid. Ignoring this parameter. + The option specified with blame, {0} is invalid. This will be ignored. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.pl.xlf b/src/vstest.console/Resources/xlf/Resources.pl.xlf index 12931af6d2..293e5991fd 100644 --- a/src/vstest.console/Resources/xlf/Resources.pl.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pl.xlf @@ -1481,11 +1481,21 @@ - --Blame|/Blame - Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. It creates an output file in the current directory as "Sequence.xml", that captures the order of execution of test before the crash. - --Blame|/Blame + --Blame|/Blame:[CollectDump];[CollectAlways]=[Value];[DumpType]=[Value] + Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. + It creates an output file in the current directory as "Sequence.xml", + that captures the order of execution of test before the crash. + You may optionally choose to collect process dump for the test host. + When you choose to collect dump, by default, a mini dump will be collected on a crash. + You may also choose to override this default behaviour by some optional parameters: + CollectAlways - To collect dump on exit even if there is no crash (true/false) + DumpType - To specify dump type (mini/full). + Example: /Blame + /Blame:CollectDump + /Blame:CollectDump;CollectAlways=true;DumpType=full + --Blame|/Blame Uruchamia test w trybie Blame. Ta opcja jest przydatna przy izolowaniu problematycznego testu powodującego awarię hosta testów. Tworzy w bieżącym katalogu plik wyjściowy „Sequence.xml”, który przechwytuje kolejność wykonywania testu przed awarią. - + Test Run Aborted. @@ -1577,6 +1587,16 @@ Opcja CollectDump dla narzędzia Blame nie jest obsługiwana na tej platformie. + + The blame option specified '{0}' is not a valid format. Please correct it and retry. + The blame option specified '{0}' is not valid. This will be ignored. + + + + The blame parameter specified with blame, {0} is invalid. Ignoring this parameter. + The option specified with blame, {0} is invalid. This will be ignored. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf index 2b27ac4c3d..fcbead77bb 100644 --- a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf @@ -1481,11 +1481,21 @@ - --Blame|/Blame - Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. It creates an output file in the current directory as "Sequence.xml", that captures the order of execution of test before the crash. - --Blame|/Blame + --Blame|/Blame:[CollectDump];[CollectAlways]=[Value];[DumpType]=[Value] + Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. + It creates an output file in the current directory as "Sequence.xml", + that captures the order of execution of test before the crash. + You may optionally choose to collect process dump for the test host. + When you choose to collect dump, by default, a mini dump will be collected on a crash. + You may also choose to override this default behaviour by some optional parameters: + CollectAlways - To collect dump on exit even if there is no crash (true/false) + DumpType - To specify dump type (mini/full). + Example: /Blame + /Blame:CollectDump + /Blame:CollectDump;CollectAlways=true;DumpType=full + --Blame|/Blame Executa o teste em modo de acusação. Essa opção é útil para isolar o teste problemático causando uma falha no host de teste. Ele cria um arquivo de saída no diretório atual como "Sequence.xml", que captura a ordem de execução do teste antes da falha. - + Test Run Aborted. @@ -1577,6 +1587,16 @@ A opção CollectDump para Blame não é compatível com esta plataforma. + + The blame option specified '{0}' is not a valid format. Please correct it and retry. + The blame option specified '{0}' is not valid. This will be ignored. + + + + The blame parameter specified with blame, {0} is invalid. Ignoring this parameter. + The option specified with blame, {0} is invalid. This will be ignored. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.ru.xlf b/src/vstest.console/Resources/xlf/Resources.ru.xlf index 66b8ffde4d..fa1cbe992c 100644 --- a/src/vstest.console/Resources/xlf/Resources.ru.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ru.xlf @@ -1482,11 +1482,21 @@ - --Blame|/Blame - Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. It creates an output file in the current directory as "Sequence.xml", that captures the order of execution of test before the crash. - --Blame|/Blame + --Blame|/Blame:[CollectDump];[CollectAlways]=[Value];[DumpType]=[Value] + Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. + It creates an output file in the current directory as "Sequence.xml", + that captures the order of execution of test before the crash. + You may optionally choose to collect process dump for the test host. + When you choose to collect dump, by default, a mini dump will be collected on a crash. + You may also choose to override this default behaviour by some optional parameters: + CollectAlways - To collect dump on exit even if there is no crash (true/false) + DumpType - To specify dump type (mini/full). + Example: /Blame + /Blame:CollectDump + /Blame:CollectDump;CollectAlways=true;DumpType=full + --Blame|/Blame Запускает тест в режиме обвинения. Этот параметр нужен, чтобы изолировать проблемный тест, вызывающий сбой хоста для тестов. Он создает файл выходных данных в текущем каталоге (Sequence.xml), в котором записывается порядок выполнения теста перед сбоем. - + Test Run Aborted. @@ -1579,6 +1589,16 @@ Параметр CollectDump для Blame не поддерживается на этой платформе. + + The blame option specified '{0}' is not a valid format. Please correct it and retry. + The blame option specified '{0}' is not valid. This will be ignored. + + + + The blame parameter specified with blame, {0} is invalid. Ignoring this parameter. + The option specified with blame, {0} is invalid. This will be ignored. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.tr.xlf b/src/vstest.console/Resources/xlf/Resources.tr.xlf index 6abe9d22c4..2c2bfa0cbb 100644 --- a/src/vstest.console/Resources/xlf/Resources.tr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.tr.xlf @@ -1482,11 +1482,21 @@ - --Blame|/Blame - Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. It creates an output file in the current directory as "Sequence.xml", that captures the order of execution of test before the crash. - --Blame|/Blame + --Blame|/Blame:[CollectDump];[CollectAlways]=[Value];[DumpType]=[Value] + Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. + It creates an output file in the current directory as "Sequence.xml", + that captures the order of execution of test before the crash. + You may optionally choose to collect process dump for the test host. + When you choose to collect dump, by default, a mini dump will be collected on a crash. + You may also choose to override this default behaviour by some optional parameters: + CollectAlways - To collect dump on exit even if there is no crash (true/false) + DumpType - To specify dump type (mini/full). + Example: /Blame + /Blame:CollectDump + /Blame:CollectDump;CollectAlways=true;DumpType=full + --Blame|/Blame Testi blame modunda çalıştırır. Bu seçenek, test konağı kilitlenmesine neden olan sorunlu testi belirlemek için kullanışlıdır. Geçerli dizinde testin kilitlenmeden önceki çalıştırılma sırasını yakalayan "Sequence.xml" adlı bir çıkış dosyası oluşturur. - + Test Run Aborted. @@ -1579,6 +1589,16 @@ Blame için CollectDump seçeneği bu platformda desteklenmez. + + The blame option specified '{0}' is not a valid format. Please correct it and retry. + The blame option specified '{0}' is not valid. This will be ignored. + + + + The blame parameter specified with blame, {0} is invalid. Ignoring this parameter. + The option specified with blame, {0} is invalid. This will be ignored. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.xlf b/src/vstest.console/Resources/xlf/Resources.xlf index 08b70745ed..f831e0553e 100644 --- a/src/vstest.console/Resources/xlf/Resources.xlf +++ b/src/vstest.console/Resources/xlf/Resources.xlf @@ -669,8 +669,18 @@ - --Blame|/Blame - Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. It creates an output file in the current directory as "Sequence.xml", that captures the order of execution of test before the crash. + --Blame|/Blame:[CollectDump];[CollectAlways]=[Value];[DumpType]=[Value] + Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. + It creates an output file in the current directory as "Sequence.xml", + that captures the order of execution of test before the crash. + You may optionally choose to collect process dump for the test host. + When you choose to collect dump, by default, a mini dump will be collected on a crash. + You may also choose to override this default behaviour by some optional parameters: + CollectAlways - To collect dump on exit even if there is no crash (true/false) + DumpType - To specify dump type (mini/full). + Example: /Blame + /Blame:CollectDump + /Blame:CollectDump;CollectAlways=true;DumpType=full --Blame|/Blame Enable Blame mode to get name of the faulty test case in event of a test host crash. @@ -775,6 +785,16 @@ CollectDump option for Blame is not supported for this platform. + + The blame option specified '{0}' is not a valid format. Please correct it and retry. + The blame option specified '{0}' is not valid. This will be ignored. + + + + The blame parameter specified with blame, {0} is invalid. Ignoring this parameter. + The option specified with blame, {0} is invalid. This will be ignored. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf index c4b72f72ee..923efbcf74 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf @@ -1482,11 +1482,21 @@ - --Blame|/Blame - Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. It creates an output file in the current directory as "Sequence.xml", that captures the order of execution of test before the crash. - --Blame|/Blame + --Blame|/Blame:[CollectDump];[CollectAlways]=[Value];[DumpType]=[Value] + Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. + It creates an output file in the current directory as "Sequence.xml", + that captures the order of execution of test before the crash. + You may optionally choose to collect process dump for the test host. + When you choose to collect dump, by default, a mini dump will be collected on a crash. + You may also choose to override this default behaviour by some optional parameters: + CollectAlways - To collect dump on exit even if there is no crash (true/false) + DumpType - To specify dump type (mini/full). + Example: /Blame + /Blame:CollectDump + /Blame:CollectDump;CollectAlways=true;DumpType=full + --Blame|/Blame 在追责模式下运行测试。此选项有助于隔离有问题的测试,以免导致测试主机崩溃。它会在当前目录中创建一个输出文件 "Sequence.xml",用于在崩溃之前捕获测试的执行顺序。 - + Test Run Aborted. @@ -1579,6 +1589,16 @@ 此平台不支持用于追责的 CollectDump 选项。 + + The blame option specified '{0}' is not a valid format. Please correct it and retry. + The blame option specified '{0}' is not valid. This will be ignored. + + + + The blame parameter specified with blame, {0} is invalid. Ignoring this parameter. + The option specified with blame, {0} is invalid. This will be ignored. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf index bf7c97abba..8f5cc110b0 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf @@ -1482,11 +1482,21 @@ - --Blame|/Blame - Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. It creates an output file in the current directory as "Sequence.xml", that captures the order of execution of test before the crash. - --Blame|/Blame + --Blame|/Blame:[CollectDump];[CollectAlways]=[Value];[DumpType]=[Value] + Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. + It creates an output file in the current directory as "Sequence.xml", + that captures the order of execution of test before the crash. + You may optionally choose to collect process dump for the test host. + When you choose to collect dump, by default, a mini dump will be collected on a crash. + You may also choose to override this default behaviour by some optional parameters: + CollectAlways - To collect dump on exit even if there is no crash (true/false) + DumpType - To specify dump type (mini/full). + Example: /Blame + /Blame:CollectDump + /Blame:CollectDump;CollectAlways=true;DumpType=full + --Blame|/Blame 在 Blame 模式中執行測試。此選項有助於隔離造成測試主機損毀的問題測試。其會在目前的目錄中建立 "Sequence.xml" 這樣的輸出檔案,以擷取損毀前執行測試的順序。 - + Test Run Aborted. @@ -1579,6 +1589,16 @@ 對此平台不支援 Blame 的 CollectDump 選項。 + + The blame option specified '{0}' is not a valid format. Please correct it and retry. + The blame option specified '{0}' is not valid. This will be ignored. + + + + The blame parameter specified with blame, {0} is invalid. Ignoring this parameter. + The option specified with blame, {0} is invalid. This will be ignored. + + \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/BlameCollectorTests.cs b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/BlameCollectorTests.cs index 3bd9849e9f..4d78f51064 100644 --- a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/BlameCollectorTests.cs +++ b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/BlameCollectorTests.cs @@ -5,6 +5,7 @@ namespace Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests { using System; using System.Collections.Generic; + using System.Globalization; using System.IO; using System.Xml; @@ -63,14 +64,14 @@ public BlameCollectorTests() public void InitializeShouldThrowExceptionIfDataCollectionLoggerIsNull() { Assert.ThrowsException(() => - { - this.blameDataCollector.Initialize( - this.configurationElement, - this.mockDataColectionEvents.Object, - this.mockDataCollectionSink.Object, - null, - null); - }); + { + this.blameDataCollector.Initialize( + this.configurationElement, + this.mockDataColectionEvents.Object, + this.mockDataCollectionSink.Object, + null, + null); + }); } /// @@ -142,6 +143,63 @@ public void TriggerSessionEndedHandlerShouldGetDumpFileIfProcDumpEnabled() // Setup this.mockProcessDumpUtility.Setup(x => x.GetDumpFile()).Returns(this.filepath); + this.mockBlameReaderWriter.Setup(x => x.WriteTestSequence(It.IsAny>(), It.IsAny())) + .Returns(this.filepath); + + // Raise + 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)); + + // Verify GetDumpFiles Call + this.mockProcessDumpUtility.Verify(x => x.GetDumpFile(), Times.Once); + } + + /// + /// The trigger session ended handler should not dump files if proc dump was enabled and test host did not crash + /// + [TestMethod] + public void TriggerSessionEndedHandlerShouldNotGetDumpFileIfNoCrash() + { + // Initializing Blame Data Collector + this.blameDataCollector.Initialize( + this.GetDumpConfigurationElement(), + this.mockDataColectionEvents.Object, + this.mockDataCollectionSink.Object, + this.mockLogger.Object, + this.context); + + // Setup + this.mockProcessDumpUtility.Setup(x => x.GetDumpFile()).Returns(this.filepath); + this.mockBlameReaderWriter.Setup(x => x.WriteTestSequence(It.IsAny>(), It.IsAny())) + .Returns(this.filepath); + + // Raise + this.mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(this.dataCollectionContext, 1234)); + this.mockDataColectionEvents.Raise(x => x.SessionEnd += null, new SessionEndEventArgs(this.dataCollectionContext)); + + // Verify GetDumpFiles Call + this.mockProcessDumpUtility.Verify(x => x.GetDumpFile(), Times.Never); + } + + /// + /// The trigger session ended handler should get dump files if collect dump on exit was enabled irrespective of completed test case count + /// + [TestMethod] + public void TriggerSessionEndedHandlerShouldGetDumpFileIfCollectDumpOnExitIsEnabled() + { + // Initializing Blame Data Collector + this.blameDataCollector.Initialize( + this.GetDumpConfigurationElement(collectDumpOnExit: true), + this.mockDataColectionEvents.Object, + this.mockDataCollectionSink.Object, + this.mockLogger.Object, + this.context); + + // Setup + this.mockProcessDumpUtility.Setup(x => x.GetDumpFile()).Returns(this.filepath); + this.mockBlameReaderWriter.Setup(x => x.WriteTestSequence(It.IsAny>(), It.IsAny())) + .Returns(this.filepath); // Raise this.mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(this.dataCollectionContext, 1234)); @@ -166,8 +224,11 @@ public void TriggerSessionEndedHandlerShouldLogWarningIfGetDumpFileThrowsFileNot this.context); // Setup and raise events + this.mockBlameReaderWriter.Setup(x => x.WriteTestSequence(It.IsAny>(), It.IsAny())) + .Returns(this.filepath); this.mockProcessDumpUtility.Setup(x => x.GetDumpFile()).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)); // Verify GetDumpFiles Call @@ -192,7 +253,135 @@ public void TriggerTestHostLaunchedHandlerShouldStartProcDumpUtilityIfProcDumpEn this.mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(this.dataCollectionContext, 1234)); // Verify StartProcessDumpCall - this.mockProcessDumpUtility.Verify(x => x.StartProcessDump(1234, It.IsAny(), It.IsAny())); + this.mockProcessDumpUtility.Verify(x => x.StartProcessDump(1234, It.IsAny(), It.IsAny(), false)); + } + + /// + /// The trigger test host launched handler should start process dump utility for full dump if full dump was enabled + /// + [TestMethod] + public void TriggerTestHostLaunchedHandlerShouldStartProcDumpUtilityForFullDumpIfFullDumpEnabled() + { + // Initializing Blame Data Collector + this.blameDataCollector.Initialize( + this.GetDumpConfigurationElement(isFullDump: true), + 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 StartProcessDumpCall + this.mockProcessDumpUtility.Verify(x => x.StartProcessDump(1234, It.IsAny(), It.IsAny(), true)); + } + + /// + /// The trigger test host launched handler should start process dump utility for full dump if full dump was enabled + /// + [TestMethod] + public void TriggerTestHostLaunchedHandlerShouldStartProcDumpUtilityForFullDumpIfFullDumpEnabledCaseSensitivity() + { + var dumpConfig = this.GetDumpConfigurationElement(); + var dumpTypeAttribute = dumpConfig.OwnerDocument.CreateAttribute("DuMpType"); + dumpTypeAttribute.Value = "FuLl"; + dumpConfig[BlameDataCollector.Constants.DumpModeKey].Attributes.Append(dumpTypeAttribute); + var dumpOnExitAttribute = dumpConfig.OwnerDocument.CreateAttribute("CollEctAlways"); + dumpOnExitAttribute.Value = "FaLSe"; + dumpConfig[BlameDataCollector.Constants.DumpModeKey].Attributes.Append(dumpOnExitAttribute); + + // 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 StartProcessDumpCall + this.mockProcessDumpUtility.Verify(x => x.StartProcessDump(1234, It.IsAny(), It.IsAny(), true)); + } + + /// + /// The trigger test host launched handler should start process dump utility for full dump if full dump was enabled + /// + [TestMethod] + public void TriggerTestHostLaunchedHandlerShouldLogWarningForWrongCollectDumpKey() + { + var dumpConfig = this.GetDumpConfigurationElement(); + var dumpTypeAttribute = dumpConfig.OwnerDocument.CreateAttribute("Xyz"); + dumpTypeAttribute.Value = "FuLl"; + dumpConfig[BlameDataCollector.Constants.DumpModeKey].Attributes.Append(dumpTypeAttribute); + + // 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.Is(str => str == string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterKeyIncorrect, "Xyz"))), Times.Once); + } + + /// + /// The trigger test host launched handler should start process dump utility for full dump if full dump was enabled + /// + [TestMethod] + public void TriggerTestHostLaunchedHandlerShouldLogWarningForWrongDumpType() + { + var dumpConfig = this.GetDumpConfigurationElement(); + var dumpTypeAttribute = dumpConfig.OwnerDocument.CreateAttribute("DumpType"); + dumpTypeAttribute.Value = "random"; + dumpConfig[BlameDataCollector.Constants.DumpModeKey].Attributes.Append(dumpTypeAttribute); + + // 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.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 TriggerTestHostLaunchedHandlerShouldLogWarningForNonBooleanCollectAlwaysValue() + { + var dumpConfig = this.GetDumpConfigurationElement(); + var dumpTypeAttribute = dumpConfig.OwnerDocument.CreateAttribute("DumpType"); + dumpTypeAttribute.Value = "random"; + dumpConfig[BlameDataCollector.Constants.DumpModeKey].Attributes.Append(dumpTypeAttribute); + + // 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.Is(str => str == string.Format(CultureInfo.CurrentUICulture, Resources.Resources.BlameParameterValueIncorrect, "DumpType", BlameDataCollector.Constants.FullConfigurationValue, BlameDataCollector.Constants.MiniConfigurationValue))), Times.Once); } /// @@ -211,14 +400,14 @@ public void TriggerTestHostLaunchedHandlerShouldCatchTestPlatFormExceptionsAndRe // Make StartProcessDump throw exception var tpex = new TestPlatformException("env var exception"); - this.mockProcessDumpUtility.Setup(x => x.StartProcessDump(1234, It.IsAny(), It.IsAny())) + this.mockProcessDumpUtility.Setup(x => x.StartProcessDump(1234, It.IsAny(), It.IsAny(), false)) .Throws(tpex); // Raise TestHostLaunched this.mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(this.dataCollectionContext, 1234)); // Verify - this.mockLogger.Verify(x => x.LogWarning(It.IsAny(), It.Is(str => str == tpex.Message)), Times.Once); + this.mockLogger.Verify(x => x.LogWarning(It.IsAny(), It.Is(str => str == string.Format(CultureInfo.CurrentUICulture, Resources.Resources.ProcDumpCouldNotStart, tpex.Message))), Times.Once); } /// @@ -237,14 +426,14 @@ public void TriggerTestHostLaunchedHandlerShouldCatchAllUnexpectedExceptionsAndR // Make StartProcessDump throw exception var ex = new Exception("start process failed"); - this.mockProcessDumpUtility.Setup(x => x.StartProcessDump(1234, It.IsAny(), It.IsAny())) + this.mockProcessDumpUtility.Setup(x => x.StartProcessDump(1234, It.IsAny(), It.IsAny(), false)) .Throws(ex); // Raise TestHostLaunched this.mockDataColectionEvents.Raise(x => x.TestHostLaunched += null, new TestHostLaunchedEventArgs(this.dataCollectionContext, 1234)); // Verify - this.mockLogger.Verify(x => x.LogWarning(It.IsAny(), It.Is(str => str == ex.ToString())), Times.Once); + this.mockLogger.Verify(x => x.LogWarning(It.IsAny(), It.Is(str => str == string.Format(CultureInfo.CurrentUICulture, Resources.Resources.ProcDumpCouldNotStart, ex.ToString()))), Times.Once); } [TestCleanup] @@ -253,13 +442,26 @@ public void CleanUp() File.Delete(this.filepath); } - private XmlElement GetDumpConfigurationElement() + private XmlElement GetDumpConfigurationElement(bool isFullDump = false, bool collectDumpOnExit = false) { var xmldoc = new XmlDocument(); var outernode = xmldoc.CreateElement("Configuration"); var node = xmldoc.CreateElement(BlameDataCollector.Constants.DumpModeKey); outernode.AppendChild(node); node.InnerText = "Text"; + if (isFullDump) + { + var fulldumpAttribute = xmldoc.CreateAttribute(BlameDataCollector.Constants.DumpTypeKey); + fulldumpAttribute.Value = "full"; + node.Attributes.Append(fulldumpAttribute); + } + + if (collectDumpOnExit) + { + var fulldumpAttribute = xmldoc.CreateAttribute(BlameDataCollector.Constants.CollectDumpAlwaysKey); + fulldumpAttribute.Value = "true"; + node.Attributes.Append(fulldumpAttribute); + } return outernode; } diff --git a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/ProcessDumpUtilityTests.cs b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/ProcessDumpUtilityTests.cs index 57fa1d51fe..ae63dc5e09 100644 --- a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/ProcessDumpUtilityTests.cs +++ b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/ProcessDumpUtilityTests.cs @@ -123,6 +123,34 @@ public void StartProcessDumpWillStartProcDumpExeWithCorrectParamsAndGetDumpFileR Assert.AreEqual(Path.Combine(testResultsDirectory, filename), processDumpUtility.GetDumpFile()); } + /// + /// StartProcessDump should start procdump binary with correct full dump arguments, while GetDumpFile returns full path + /// + [TestMethod] + public void StartProcessDumpWillStartProcDumpExeWithCorrectParamsForFullDump() + { + var guid = "guid"; + var process = "process"; + var processId = 12345; + var filename = $"{process}_{processId}_{guid}.dmp"; + var args = $"-accepteula -t -ma {processId} {filename}"; + var testResultsDirectory = "D:\\TestResults"; + + this.mockProcessHelper.Setup(x => x.LaunchProcess(It.IsAny(), It.IsAny(), It.IsAny(), null, null, null)) + .Returns(this.mockProcDumpProcess.Object); + this.mockProcessHelper.Setup(x => x.GetProcessName(processId)) + .Returns(process); + + this.mockFileHelper.Setup(x => x.GetFiles(It.IsAny(), It.IsAny(), It.IsAny())) + .Returns(new string[] { Path.Combine(testResultsDirectory, filename) }); + + var processDumpUtility = new ProcessDumpUtility(this.mockProcessHelper.Object, this.mockFileHelper.Object, this.mockPlatformEnvironment.Object); + processDumpUtility.StartProcessDump(processId, guid, testResultsDirectory, isFullDump: true); + + this.mockProcessHelper.Verify(x => x.LaunchProcess(It.IsAny(), args, It.IsAny(), null, null, null), Times.Once); + Assert.AreEqual(Path.Combine(testResultsDirectory, filename), processDumpUtility.GetDumpFile()); + } + /// /// Start process dump will throw error if PROCDUMP_PATH env variable is not set /// diff --git a/test/vstest.console.UnitTests/Processors/EnableBlameArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/EnableBlameArgumentProcessorTests.cs index c2edc7b7e5..66c12096cf 100644 --- a/test/vstest.console.UnitTests/Processors/EnableBlameArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/EnableBlameArgumentProcessorTests.cs @@ -5,6 +5,8 @@ namespace vstest.console.UnitTests.Processors { using System; using System.Collections.Generic; + using System.Globalization; + using Microsoft.VisualStudio.TestPlatform.CommandLine; using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; using Microsoft.VisualStudio.TestPlatform.Common; using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; @@ -78,6 +80,20 @@ public void InitializeShouldCreateEntryForBlameInRunSettingsIfNotAlreadyPresent( 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); } + [TestMethod] + 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"); + 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); + } + [TestMethod] public void InitializeShouldWarnIfPlatformNotSupportedForCollectDumpOption() { @@ -92,7 +108,7 @@ public void InitializeShouldWarnIfPlatformNotSupportedForCollectDumpOption() Tuple.Create(PlatformOperatingSystem.Windows, PlatformArchitecture.ARM), Tuple.Create(PlatformOperatingSystem.Windows, PlatformArchitecture.ARM64) }; - + foreach (var tuple in unsupportedPlatforms) { this.mockEnvronment.SetupGet(s => s.OperatingSystem).Returns(tuple.Item1); @@ -106,6 +122,49 @@ public void InitializeShouldWarnIfPlatformNotSupportedForCollectDumpOption() } } + [TestMethod] + public void InitializeShouldWarnIfIncorrectorParameterIsSpecifiedForCollectDumpOption() + { + var invalidParameter = "CollectDumpXX"; + 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(invalidParameter); + 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); + } + + [TestMethod] + [ExpectedException(typeof(CommandLineException))] + public void InitializeShouldThrowIfInvalidParameterFormatIsSpecifiedForCollectDumpOption() + { + var invalidString = "CollectDump;sdf=sdg;;as;a="; + 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(invalidString); + this.mockOutput.Verify(x => x.WriteLine(string.Format(CultureInfo.CurrentUICulture, CommandLineResources.BlameInvalidFormat, 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); + } + [TestMethod] public void InitializeShouldCreateEntryForBlameAlongWithCollectDumpEntryIfEnabled() { @@ -125,6 +184,25 @@ public void InitializeShouldCreateEntryForBlameAlongWithCollectDumpEntryIfEnable 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); } + [TestMethod] + public void InitializeShouldCreateEntryForBlameAlongWithCollectDumpParametersIfEnabled() + { + 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("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); + } + internal class TestableEnableBlameArgumentExecutor : EnableBlameArgumentExecutor { internal TestableEnableBlameArgumentExecutor(IRunSettingsProvider runSettingsManager, IEnvironment environment, IOutput output)