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

Progress indicator. #1964

Merged
merged 11 commits into from
Mar 26, 2019
Merged

Progress indicator. #1964

merged 11 commits into from
Mar 26, 2019

Conversation

singhsarab
Copy link
Contributor

Description

Adding the code for indicating that the run is in progress.

Related issue

#1824

@singhsarab singhsarab requested a review from abhishkk March 20, 2019 20:04
@singhsarab singhsarab marked this pull request as ready for review March 22, 2019 18:36
@singhsarab singhsarab changed the title Draft for the progress indicator. Progress indicator. Mar 25, 2019
@@ -336,6 +353,8 @@ private void TestMessageHandler(object sender, TestRunMessageEventArgs e)
ValidateArg.NotNull<object>(sender, "sender");
ValidateArg.NotNull<TestRunMessageEventArgs>(e, "e");

this.progressIndicator.Pause();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a note here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

// Use the no operation progress indicator is the standard out is getting redirected.
if (Console.IsOutputRedirected)
{
this.progressIndicator = new NoOpProgressIndicator();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As NoOpProgressIndicator implementation is empty, we can initialize this.progressIndicator only when console output is not redirected. In other case, it will be null.

Now anywhere we are using this.progressIndicator.Pause();, we can do this.progressIndicator?.Pause();


namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Internal
{
internal class NoOpProgressIndicator : IProgressIndicator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case we are removing NoOpProgressIndicator, we can remove interface as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need it for testing.


namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Internal
{
using Microsoft.VisualStudio.TestPlatform.Utilities;
Copy link
Contributor

@abhishkk abhishkk Mar 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: system using sort

using System;
using Timer = System.Timers.Timer;

public class ProgressIndicator : IProgressIndicator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can make class internal

{
lock (syncObject)
{
if (timer == null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can make timer private property and move these 3-4 line to getter.

timer.Start();
}
startTime = DateTime.Now;
ConsoleOutput.Write(testRunProgressString.Substring(0, testRunProgressString.Length + dotCounter - 2), OutputLevel.Information);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we write a note here why we are doing substr?

var currentLineCursor = Console.CursorTop;
Console.SetCursorPosition(startPos, Console.CursorTop);
ConsoleOutput.Write(new string(' ', Console.WindowWidth - startPos), OutputLevel.Information);
Console.SetCursorPosition(startPos, currentLineCursor);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can add note here as well

{
ConsoleOutput.Write(".", OutputLevel.Information);
dotCounter = ++dotCounter % 3;
if (dotCounter == 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets add note for this scenario as well

Console.SetCursorPosition(startPos, currentLineCursor);
}

public void Pause()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To test pause, start, stop, can we create consoleWrapper so as to check functionalities like:

  1. pause is pausing the indicator
  2. pause is clearing/setting the cursor point
  3. stop is stopping the timer
    etc.

@microsoft microsoft deleted a comment from abhishkk Mar 25, 2019
@microsoft microsoft deleted a comment from abhishkk Mar 25, 2019
Copy link
Contributor

@abhishkk abhishkk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to regenerate resources again.

if (this.progressIndicator == null && !Console.IsOutputRedirected)
{
// Progress indicator needs to be displayed only for cli experience.
// Use the no operation progress indicator is the standard out is getting redirected.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: line comment seems incorrect

/// <summary>
/// Interface for wrapping the Console class
/// </summary>
public interface IConsoleHelper
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: internal interface


namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Internal
{
public interface IProgressIndicator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: internal interface

lock (syncObject)
{
IsRunning = false;
Clear(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this.Clear(0)

@@ -1637,6 +1637,11 @@
<target state="new">Zadání Framework35 není podporováno. U projektů mířících na .Net Framework 3.5 prosím použijte Framework40, aby testy v CLR 4.0 běžely v režimu kompatibility.</target>
<note></note>
</trans-unit>
<trans-unit id="ProgressIndicatorString">
<source>Test run in progress</source>
<target state="new">Test run in progress...</target>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to re-generate the resources. It's still picking old value

@jorgensigvardsson
Copy link

So, has this change surfaced to the public yet? Running 2.2.204 SDK docker image for now. Should I keep on doing that until 3.0 is out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants