diff --git a/src/Platform/Microsoft.Testing.Platform/Builder/TestApplication.cs b/src/Platform/Microsoft.Testing.Platform/Builder/TestApplication.cs index fc8c2870ef..4ee303edd6 100644 --- a/src/Platform/Microsoft.Testing.Platform/Builder/TestApplication.cs +++ b/src/Platform/Microsoft.Testing.Platform/Builder/TestApplication.cs @@ -78,6 +78,11 @@ public static async Task CreateBuilderAsync(string[] ar // First step is to parse the command line from where we get the second input layer. // The first one should be the env vars handled autonomously by extensions and part of the test platform. CommandLineParseResult parseResult = CommandLineParser.Parse(args, systemEnvironment); + if (parseResult.IsOptionSet(PlatformCommandLineProvider.DebugAttachOptionKey)) + { + WaitForDebuggerToAttach(systemEnvironment, systemConsole, systemProcess); + } + TestHostControllerInfo testHostControllerInfo = new(parseResult); CurrentTestApplicationModuleInfo testApplicationModuleInfo = new(systemEnvironment, systemProcess); @@ -230,16 +235,21 @@ private static void AttachDebuggerIfNeeded(SystemEnvironment environment, System if (environment.GetEnvironmentVariable(EnvironmentVariableConstants.TESTINGPLATFORM_WAIT_ATTACH_DEBUGGER) == "1") { - using IProcess currentProcess = systemProcess.GetCurrentProcess(); - console.WriteLine($"Waiting for debugger to attach... Process Id: {environment.ProcessId}, Name: {currentProcess.Name}"); + WaitForDebuggerToAttach(environment, console, systemProcess); + } + } - while (!Debugger.IsAttached) - { - Thread.Sleep(1000); - } + private static void WaitForDebuggerToAttach(SystemEnvironment environment, SystemConsole console, SystemProcessHandler systemProcess) + { + using IProcess currentProcess = systemProcess.GetCurrentProcess(); + console.WriteLine($"Waiting for debugger to attach... Process Id: {environment.ProcessId}, Name: {currentProcess.Name}"); - Debugger.Break(); + while (!Debugger.IsAttached) + { + Thread.Sleep(1000); } + + Debugger.Break(); } /* diff --git a/src/Platform/Microsoft.Testing.Platform/CommandLine/PlatformCommandLineProvider.cs b/src/Platform/Microsoft.Testing.Platform/CommandLine/PlatformCommandLineProvider.cs index 5f1b3f192b..777497f217 100644 --- a/src/Platform/Microsoft.Testing.Platform/CommandLine/PlatformCommandLineProvider.cs +++ b/src/Platform/Microsoft.Testing.Platform/CommandLine/PlatformCommandLineProvider.cs @@ -29,6 +29,7 @@ internal sealed class PlatformCommandLineProvider : ICommandLineOptionsProvider public const string ExitOnProcessExitOptionKey = "exit-on-process-exit"; public const string ConfigFileOptionKey = "config-file"; public const string FilterUidOptionKey = "filter-uid"; + public const string DebugAttachOptionKey = "debug-wait-attach"; public const string ServerOptionKey = "server"; public const string ClientPortOptionKey = "client-port"; @@ -59,6 +60,7 @@ internal sealed class PlatformCommandLineProvider : ICommandLineOptionsProvider new(ExitOnProcessExitOptionKey, PlatformResources.PlatformCommandLineExitOnProcessExitOptionDescription, ArgumentArity.ExactlyOne, false, isBuiltIn: true), new(ConfigFileOptionKey, PlatformResources.PlatformCommandLineConfigFileOptionDescription, ArgumentArity.ExactlyOne, false, isBuiltIn: true), new(FilterUidOptionKey, PlatformResources.PlatformCommandLineFilterUidOptionDescription, ArgumentArity.OneOrMore, false, isBuiltIn: true), + new(DebugAttachOptionKey, PlatformResources.PlatformCommandLineDebugAttachOptionDescription, ArgumentArity.Zero, false, isBuiltIn: true), // Hidden options new(HelpOptionQuestionMark, PlatformResources.PlatformCommandLineHelpOptionDescription, ArgumentArity.Zero, true, isBuiltIn: true), diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx b/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx index 9ca55934cd..a3c8767c8f 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx +++ b/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx @@ -713,4 +713,7 @@ Takes one argument as string in the format <value>[h|m|s] where 'value' is Passing both '--treenode-filter' and '--filter-uid' is unsupported. - + + Allows to pause execution in order to attach to the process for debug purposes. + + \ No newline at end of file diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf index 2dd7c37384..d7788c81b0 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf @@ -466,6 +466,11 @@ Určuje soubor testconfig.json. + + Allows to pause execution in order to attach to the process for debug purposes. + Allows to pause execution in order to attach to the process for debug purposes. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf index 2901eea04a..a739f627ef 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf @@ -466,6 +466,11 @@ Gibt eine testconfig.json-Datei an. + + Allows to pause execution in order to attach to the process for debug purposes. + Allows to pause execution in order to attach to the process for debug purposes. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf index 613ea681c3..5d78b736ff 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf @@ -466,6 +466,11 @@ Especifica un archivo testconfig.json. + + Allows to pause execution in order to attach to the process for debug purposes. + Allows to pause execution in order to attach to the process for debug purposes. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf index 6ac9dfb271..5460814520 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf @@ -466,6 +466,11 @@ Spécifie un fichier testconfig.json. + + Allows to pause execution in order to attach to the process for debug purposes. + Allows to pause execution in order to attach to the process for debug purposes. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf index e2b61cae0c..f810f98b81 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf @@ -466,6 +466,11 @@ Specifica un file testconfig.json. + + Allows to pause execution in order to attach to the process for debug purposes. + Allows to pause execution in order to attach to the process for debug purposes. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf index 1998a73c03..e08f96a303 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf @@ -466,6 +466,11 @@ testconfig.json ファイルを指定します。 + + Allows to pause execution in order to attach to the process for debug purposes. + Allows to pause execution in order to attach to the process for debug purposes. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf index e2d0097ada..3b7c2d118a 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf @@ -466,6 +466,11 @@ testconfig.json 파일을 지정합니다. + + Allows to pause execution in order to attach to the process for debug purposes. + Allows to pause execution in order to attach to the process for debug purposes. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf index 9f96ada5b5..b22b0c5fad 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf @@ -466,6 +466,11 @@ Określa plik testconfig.json. + + Allows to pause execution in order to attach to the process for debug purposes. + Allows to pause execution in order to attach to the process for debug purposes. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf index a0884e336d..25cef70f6d 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf @@ -466,6 +466,11 @@ Especifica um arquivo testconfig.json. + + Allows to pause execution in order to attach to the process for debug purposes. + Allows to pause execution in order to attach to the process for debug purposes. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf index e57b6d1544..0c59bd9def 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf @@ -466,6 +466,11 @@ Указывает файл testconfig.json. + + Allows to pause execution in order to attach to the process for debug purposes. + Allows to pause execution in order to attach to the process for debug purposes. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf index 4008f64005..0837ca3b32 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf @@ -466,6 +466,11 @@ testconfig.json dosyası belirtir. + + Allows to pause execution in order to attach to the process for debug purposes. + Allows to pause execution in order to attach to the process for debug purposes. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf index 5fdcc9180a..4f4cf7fd1f 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf @@ -466,6 +466,11 @@ 指定 testconfig.json 文件。 + + Allows to pause execution in order to attach to the process for debug purposes. + Allows to pause execution in order to attach to the process for debug purposes. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf index 60fd30786c..55cb5acaab 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf @@ -466,6 +466,11 @@ 指定 testconfig.json 檔案。 + + Allows to pause execution in order to attach to the process for debug purposes. + Allows to pause execution in order to attach to the process for debug purposes. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/test/IntegrationTests/MSTest.Acceptance.IntegrationTests/HelpInfoTests.cs b/test/IntegrationTests/MSTest.Acceptance.IntegrationTests/HelpInfoTests.cs index f65ad6d7c4..ac09977edf 100644 --- a/test/IntegrationTests/MSTest.Acceptance.IntegrationTests/HelpInfoTests.cs +++ b/test/IntegrationTests/MSTest.Acceptance.IntegrationTests/HelpInfoTests.cs @@ -28,6 +28,8 @@ Execute a .NET Test Application. Options: --config-file Specifies a testconfig.json file. + --debug-wait-attach + Allows to pause execution in order to attach to the process for debug purposes. --diagnostic Enable the diagnostic logging. The default log level is 'Trace'. The file will be written in the output directory with the name log_[yyMMddHHmmssfff].diag diff --git a/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoTests.cs b/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoTests.cs index 1956c917fc..0cf5d33aa6 100644 --- a/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoTests.cs +++ b/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoTests.cs @@ -22,6 +22,8 @@ Execute a .NET Test Application. Options: --config-file Specifies a testconfig.json file. + --debug-wait-attach + Allows to pause execution in order to attach to the process for debug purposes. --diagnostic Enable the diagnostic logging. The default log level is 'Trace'. The file will be written in the output directory with the name log_[yyMMddHHmmssfff].diag @@ -148,10 +150,14 @@ Microsoft.Testing.Platform v.+ \[.+\] Arity: 1 Hidden: True Description: Specify the port of the client\. - --config-file + --config-file Arity: 1 Hidden: False Description: Specifies a testconfig\.json file\. + --debug-wait-attach + Arity: 0 + Hidden: False + Description: Allows to pause execution in order to attach to the process for debug purposes. --diagnostic Arity: 0 Hidden: False @@ -279,6 +285,8 @@ Execute a .NET Test Application. Options: --config-file Specifies a testconfig.json file. + --debug-wait-attach + Allows to pause execution in order to attach to the process for debug purposes. --diagnostic Enable the diagnostic logging. The default log level is 'Trace'. The file will be written in the output directory with the name log_[yyMMddHHmmssfff].diag @@ -420,6 +428,10 @@ Microsoft.Testing.Platform v* [*] Arity: 1 Hidden: False Description: Specifies a testconfig.json file. + --debug-wait-attach + Arity: 0 + Hidden: False + Description: Allows to pause execution in order to attach to the process for debug purposes. --diagnostic Arity: 0 Hidden: False