diff --git a/src/vstest.console/CommandLine/Executor.cs b/src/vstest.console/CommandLine/Executor.cs index 4357c0af3a..225798cd6d 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,27 @@ internal int Execute(params string[] args) exitCode = 1; } + 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)) + { + var verbosity = TraceLevel.Verbose; + if (diagVerbosity != null) + { + if (Enum.TryParse(diagVerbosity, ignoreCase: true, out var parsedVerbosity)) + { + verbosity = parsedVerbosity; + } + } + + args = args.Concat(new[] { $"--diag:{diag};TraceLevel={verbosity}" }).ToArray(); + } + } + // Flatten arguments and process response files. string[] flattenedArguments; exitCode |= this.FlattenArguments(args, out flattenedArguments);