From e4288e971ae10e5b19f8595402aeae2dc2c04e1a Mon Sep 17 00:00:00 2001 From: nohwnd Date: Tue, 25 Jan 2022 11:46:36 +0100 Subject: [PATCH 1/5] Add diag log env variable --- src/vstest.console/CommandLine/Executor.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/vstest.console/CommandLine/Executor.cs b/src/vstest.console/CommandLine/Executor.cs index 4357c0af3a..ececa2990a 100644 --- a/src/vstest.console/CommandLine/Executor.cs +++ b/src/vstest.console/CommandLine/Executor.cs @@ -92,6 +92,8 @@ internal int Execute(params string[] args) { this.testPlatformEventSource.VsTestConsoleStart(); + var isDiag = args != null && args.Any(arg => arg.StartsWith("--diag", StringComparison.OrdinalIgnoreCase)); + // If User specifies --nologo via dotnet, do not print splat screen if (args != null && args.Length !=0 && args.Contains("--nologo")) { @@ -100,7 +102,6 @@ internal int Execute(params string[] args) } else { - var isDiag = args != null && args.Any(arg => arg.StartsWith("--diag", StringComparison.OrdinalIgnoreCase)); this.PrintSplashScreen(isDiag); } @@ -114,6 +115,15 @@ internal int Execute(params string[] args) exitCode = 1; } + if (!isDiag) + { + var diagLog = Environment.GetEnvironmentVariable("VSTEST_DIAGLOG"); + if (!string.IsNullOrWhiteSpace(diagLog)) + { + args = args.Concat(new[] { $"--diag:{diagLog}" }).ToArray(); + } + } + // Flatten arguments and process response files. string[] flattenedArguments; exitCode |= this.FlattenArguments(args, out flattenedArguments); From e7f4c3685fe5fe03f1146ce08333edb48b545cf9 Mon Sep 17 00:00:00 2001 From: nohwnd Date: Tue, 25 Jan 2022 14:13:26 +0100 Subject: [PATCH 2/5] Rename and use verbosity --- src/vstest.console/CommandLine/Executor.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/vstest.console/CommandLine/Executor.cs b/src/vstest.console/CommandLine/Executor.cs index ececa2990a..3c07a84473 100644 --- a/src/vstest.console/CommandLine/Executor.cs +++ b/src/vstest.console/CommandLine/Executor.cs @@ -117,10 +117,19 @@ internal int Execute(params string[] args) if (!isDiag) { - var diagLog = Environment.GetEnvironmentVariable("VSTEST_DIAGLOG"); - if (!string.IsNullOrWhiteSpace(diagLog)) + var diag = Environment.GetEnvironmentVariable("VSTEST_DIAG"); + var diagVerbosity = Environment.GetEnvironmentVariable("VSTEST_DIAG_VERBOSITY"); + if (!string.IsNullOrWhiteSpace(diag)) { - args = args.Concat(new[] { $"--diag:{diagLog}" }).ToArray(); + var verbosity = TraceLevel.Verbose; + if (diagVerbosity != null) + { + if (Enum.TryParse(diagVerbosity, ignoreCase: true, out var parsedVerbosity)) + { + verbosity = parsedVerbosity; + } + } + args = args.Concat(new[] { $"--diag:{diag};Verbosity={verbosity}" }).ToArray(); } } From 8ba3a6cd5e8c5d3fffc878db01022fbeb8295111 Mon Sep 17 00:00:00 2001 From: nohwnd Date: Tue, 25 Jan 2022 14:34:30 +0100 Subject: [PATCH 3/5] Fix parameter name --- src/vstest.console/CommandLine/Executor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vstest.console/CommandLine/Executor.cs b/src/vstest.console/CommandLine/Executor.cs index 3c07a84473..a423e32fef 100644 --- a/src/vstest.console/CommandLine/Executor.cs +++ b/src/vstest.console/CommandLine/Executor.cs @@ -129,7 +129,7 @@ internal int Execute(params string[] args) verbosity = parsedVerbosity; } } - args = args.Concat(new[] { $"--diag:{diag};Verbosity={verbosity}" }).ToArray(); + args = args.Concat(new[] { $"--diag:{diag};TraceLevel={verbosity}" }).ToArray(); } } From 80b4c19724182440fbe1ee5302657c558621e917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Tue, 25 Jan 2022 08:26:43 -0800 Subject: [PATCH 4/5] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Amaury Levé --- src/vstest.console/CommandLine/Executor.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vstest.console/CommandLine/Executor.cs b/src/vstest.console/CommandLine/Executor.cs index a423e32fef..c3c66ee19e 100644 --- a/src/vstest.console/CommandLine/Executor.cs +++ b/src/vstest.console/CommandLine/Executor.cs @@ -129,6 +129,7 @@ internal int Execute(params string[] args) verbosity = parsedVerbosity; } } + args = args.Concat(new[] { $"--diag:{diag};TraceLevel={verbosity}" }).ToArray(); } } From df61fb080f999a3a2637c5f694e309226eade4e5 Mon Sep 17 00:00:00 2001 From: nohwnd Date: Tue, 25 Jan 2022 17:27:23 +0100 Subject: [PATCH 5/5] Add comments about values --- src/vstest.console/CommandLine/Executor.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/vstest.console/CommandLine/Executor.cs b/src/vstest.console/CommandLine/Executor.cs index a423e32fef..1084892f27 100644 --- a/src/vstest.console/CommandLine/Executor.cs +++ b/src/vstest.console/CommandLine/Executor.cs @@ -117,7 +117,9 @@ internal int Execute(params string[] args) if (!isDiag) { + // This takes a path to log directory and log.txt file. Same as the --diag parameter, e.g. VSTEST_DIAG="logs\log.txt" var diag = Environment.GetEnvironmentVariable("VSTEST_DIAG"); + // This takes Verbose, Info (not Information), Warning, and Error. var diagVerbosity = Environment.GetEnvironmentVariable("VSTEST_DIAG_VERBOSITY"); if (!string.IsNullOrWhiteSpace(diag)) {