-
Notifications
You must be signed in to change notification settings - Fork 325
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
Progress indicator. #1964
Conversation
@@ -336,6 +353,8 @@ private void TestMessageHandler(object sender, TestRunMessageEventArgs e) | |||
ValidateArg.NotNull<object>(sender, "sender"); | |||
ValidateArg.NotNull<TestRunMessageEventArgs>(e, "e"); | |||
|
|||
this.progressIndicator.Pause(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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:
- pause is pausing the indicator
- pause is clearing/setting the cursor point
- stop is stopping the timer
etc.
There was a problem hiding this 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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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
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? |
Description
Adding the code for indicating that the run is in progress.
Related issue
#1824