Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add noprogress parameter to disable progress indicator #2117

Merged
merged 2 commits into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/vstest.console/Internal/ConsoleLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ internal class ConsoleLogger : ITestLoggerWithParameters
/// </summary>
internal static bool AppendPrefix;

/// <summary>
/// Bool to decide whether progress indicator should be disabled.
/// </summary>
internal static bool DisableProgress;

/// <summary>
/// Uri used to uniquely identify the console logger.
/// </summary>
Expand All @@ -75,6 +80,11 @@ internal class ConsoleLogger : ITestLoggerWithParameters
/// </summary>
public const string PrefixParam = "prefix";

/// <summary>
/// Parameter for disabling progress
/// </summary>
public const string NoProgressParam = "noprogress";

#endregion

internal enum Verbosity
Expand Down Expand Up @@ -166,7 +176,7 @@ public void Initialize(TestLoggerEvents events, string testRunDirectory)
ConsoleLogger.Output = ConsoleOutput.Instance;
}

if (this.progressIndicator == null && !Console.IsOutputRedirected)
if (this.progressIndicator == null && !Console.IsOutputRedirected && !DisableProgress)
{
// Progress indicator needs to be displayed only for cli experience.
this.progressIndicator = new ProgressIndicator(Output, new ConsoleHelper());
Expand Down Expand Up @@ -208,6 +218,12 @@ public void Initialize(TestLoggerEvents events, Dictionary<string, string> param
bool.TryParse(prefix, out AppendPrefix);
}

var noprogressExists = parameters.TryGetValue(ConsoleLogger.NoProgressParam, out string noprogress);
if (noprogressExists)
{
bool.TryParse(noprogress, out DisableProgress);
}

Initialize(events, String.Empty);
}
#endregion
Expand Down
15 changes: 15 additions & 0 deletions test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,21 @@ public void InitializeWithParametersShouldSetPrefixValue()
ConsoleLogger.AppendPrefix = false;
}

[TestMethod]
public void InitializeWithParametersShouldSetNoProgress()
{
var parameters = new Dictionary<string, string>();

Assert.IsFalse(ConsoleLogger.DisableProgress);

parameters.Add("noprogress", "true");
this.consoleLogger.Initialize(new Mock<TestLoggerEvents>().Object, parameters);

Assert.IsTrue(ConsoleLogger.DisableProgress);

ConsoleLogger.DisableProgress = false;
}

[TestMethod]
public void TestMessageHandlerShouldThrowExceptionIfEventArgsIsNull()
{
Expand Down