From 844316aee95d1ff1db158f67e1fae2571b561302 Mon Sep 17 00:00:00 2001 From: James Skimming Date: Thu, 23 May 2019 21:55:45 +0100 Subject: [PATCH] Prevent unnecessary progress indicator refresh The progress indicator is repeatedly refreshing, even in situations when a log message will not be output, e.g. when the verbosity level is not high enough. --- src/vstest.console/Internal/ConsoleLogger.cs | 58 ++++++++++++++++---- 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/src/vstest.console/Internal/ConsoleLogger.cs b/src/vstest.console/Internal/ConsoleLogger.cs index 4d02acbc16..d9d7184bf6 100644 --- a/src/vstest.console/Internal/ConsoleLogger.cs +++ b/src/vstest.console/Internal/ConsoleLogger.cs @@ -366,9 +366,6 @@ private void TestMessageHandler(object sender, TestRunMessageEventArgs e) ValidateArg.NotNull(sender, "sender"); ValidateArg.NotNull(e, "e"); - // Pause the progress indicator to print the message - this.progressIndicator?.Pause(); - switch (e.Level) { case TestMessageLevel.Informational: @@ -378,7 +375,14 @@ private void TestMessageHandler(object sender, TestRunMessageEventArgs e) break; } + // Pause the progress indicator to print the message + this.progressIndicator?.Pause(); + Output.Information(AppendPrefix, e.Message); + + // Resume the progress indicator after printing the message + this.progressIndicator?.Start(); + break; } @@ -389,23 +393,34 @@ private void TestMessageHandler(object sender, TestRunMessageEventArgs e) break; } + // Pause the progress indicator to print the message + this.progressIndicator?.Pause(); + Output.Warning(AppendPrefix, e.Message); + + // Resume the progress indicator after printing the message + this.progressIndicator?.Start(); + break; } case TestMessageLevel.Error: { + // Pause the progress indicator to print the message + this.progressIndicator?.Pause(); + this.testRunHasErrorMessages = true; Output.Error(AppendPrefix, e.Message); + + // Resume the progress indicator after printing the message + this.progressIndicator?.Start(); + break; } default: EqtTrace.Warning("ConsoleLogger.TestMessageHandler: The test message level is unrecognized: {0}", e.Level.ToString()); break; } - - // Resume the progress indicator after printing the message - this.progressIndicator?.Start(); } /// @@ -416,9 +431,6 @@ private void TestResultHandler(object sender, TestResultEventArgs e) ValidateArg.NotNull(sender, "sender"); ValidateArg.NotNull(e, "e"); - // Pause the progress indicator before displaying test result information - this.progressIndicator?.Pause(); - // Update the test count statistics based on the result of the test. this.testsTotal++; @@ -445,6 +457,9 @@ private void TestResultHandler(object sender, TestResultEventArgs e) break; } + // Pause the progress indicator before displaying test result information + this.progressIndicator?.Pause(); + Output.Write(string.Format("{0}{1} ", TestResultPrefix, SkippedTestIndicator), OutputLevel.Information, ConsoleColor.Yellow); Output.WriteLine(testDisplayName, OutputLevel.Information); if (this.verbosityLevel == Verbosity.Detailed) @@ -452,6 +467,9 @@ private void TestResultHandler(object sender, TestResultEventArgs e) DisplayFullInformation(e.Result); } + // Resume the progress indicator after displaying the test result information + this.progressIndicator?.Start(); + break; } @@ -463,9 +481,16 @@ private void TestResultHandler(object sender, TestResultEventArgs e) break; } + // Pause the progress indicator before displaying test result information + this.progressIndicator?.Pause(); + Output.Write(string.Format("{0}{1} ", TestResultPrefix, FailedTestIndicator), OutputLevel.Information, ConsoleColor.Red); Output.WriteLine(testDisplayName, OutputLevel.Information); DisplayFullInformation(e.Result); + + // Resume the progress indicator after displaying the test result information + this.progressIndicator?.Start(); + break; } @@ -474,12 +499,18 @@ private void TestResultHandler(object sender, TestResultEventArgs e) this.testsPassed++; if (this.verbosityLevel == Verbosity.Normal || this.verbosityLevel == Verbosity.Detailed) { + // Pause the progress indicator before displaying test result information + this.progressIndicator?.Pause(); + Output.Write(string.Format("{0}{1} ", TestResultPrefix, PassedTestIndicator), OutputLevel.Information, ConsoleColor.Green); Output.WriteLine(testDisplayName, OutputLevel.Information); if (this.verbosityLevel == Verbosity.Detailed) { DisplayFullInformation(e.Result); } + + // Resume the progress indicator after displaying the test result information + this.progressIndicator?.Start(); } break; @@ -492,6 +523,9 @@ private void TestResultHandler(object sender, TestResultEventArgs e) break; } + // Pause the progress indicator before displaying test result information + this.progressIndicator?.Pause(); + Output.Write(string.Format("{0}{1} ", TestResultPrefix, SkippedTestIndicator), OutputLevel.Information, ConsoleColor.Yellow); Output.WriteLine(testDisplayName, OutputLevel.Information); if (this.verbosityLevel == Verbosity.Detailed) @@ -499,12 +533,12 @@ private void TestResultHandler(object sender, TestResultEventArgs e) DisplayFullInformation(e.Result); } + // Resume the progress indicator after displaying the test result information + this.progressIndicator?.Start(); + break; } } - - // Resume the progress indicator after displaying the test result information - this.progressIndicator?.Start(); } private string GetFormattedDurationString(TimeSpan duration)