-
Notifications
You must be signed in to change notification settings - Fork 305
Show running tests #4221
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
Merged
Merged
Show running tests #4221
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
e53ae55
Terminal progress
drognanar 046c328
Fixes
nohwnd f8d84dc
Update terminal reporting to include the active tests in progress
drognanar 82e00bf
Add resource strings
drognanar 3805a59
Fixup small code style issues
drognanar bb60c96
Merge remote-tracking branch 'microsoft/main' into show_running_tests
drognanar 4bc3904
Remove long running test from playground
drognanar 5af15db
Improve distribution of the additional lines to render
drognanar 5bf23a4
Merge remote-tracking branch 'microsoft/main' into show_running_tests
drognanar f3f8469
Do not show the "... and 1 more test" message
drognanar 7fb2340
Only show tests longer than 1s
drognanar 5aed36c
Remove 1s limit when showing active tests
drognanar 7d1305c
Add an option to disable display of active tests
drognanar eb81444
Small refactorings
drognanar d2b9c82
Show "{0} tests running" if no active tests can fit on the screen
drognanar 7df3907
Add a progress indicator test
drognanar 9713409
Update src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/…
drognanar 366b428
Fix terminal logger reporter test for MacOS
drognanar 43bac64
Merge branch 'show_running_tests' of https://github.com/drognanar/tes…
drognanar e2fa5d6
Use Interlocked for _counter updates
drognanar b3e5528
Implement the stopwatch directly as a class
drognanar f7ecea0
Merge remote-tracking branch 'microsoft/main' into show_running_tests
drognanar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
251 changes: 182 additions & 69 deletions
251
...latform/Microsoft.Testing.Platform/OutputDevice/Terminal/AnsiTerminalTestProgressFrame.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TestDetailState.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| using Microsoft.Testing.Platform.Helpers; | ||
|
|
||
| namespace Microsoft.Testing.Platform.OutputDevice.Terminal; | ||
|
|
||
| internal sealed class TestDetailState | ||
| { | ||
| private string _text; | ||
|
|
||
| public TestDetailState(long id, IStopwatch? stopwatch, string text) | ||
| { | ||
| Id = id; | ||
| Stopwatch = stopwatch; | ||
| _text = text; | ||
| } | ||
|
|
||
| public long Id { get; } | ||
|
|
||
| public long Version { get; set; } | ||
|
|
||
| public IStopwatch? Stopwatch { get; } | ||
|
|
||
| public string Text | ||
| { | ||
| get => _text; | ||
| set | ||
| { | ||
| if (!_text.Equals(value, StringComparison.Ordinal)) | ||
| { | ||
| Version++; | ||
| _text = value; | ||
| } | ||
| } | ||
| } | ||
| } |
66 changes: 66 additions & 0 deletions
66
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TestNodeResultsState.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| using System.Collections.Concurrent; | ||
| using System.Globalization; | ||
|
|
||
| using Microsoft.Testing.Platform.Helpers; | ||
| using Microsoft.Testing.Platform.Resources; | ||
|
|
||
| namespace Microsoft.Testing.Platform.OutputDevice.Terminal; | ||
|
|
||
| internal sealed class TestNodeResultsState | ||
| { | ||
| public TestNodeResultsState(long id) | ||
| { | ||
| Id = id; | ||
| _summaryDetail = new(id, stopwatch: null, text: string.Empty); | ||
| } | ||
|
|
||
| public long Id { get; } | ||
|
|
||
| private readonly TestDetailState _summaryDetail; | ||
| private readonly ConcurrentDictionary<string, TestDetailState> _testNodeProgressStates = new(); | ||
|
|
||
| public int Count => _testNodeProgressStates.Count; | ||
|
|
||
| public void AddRunningTestNode(int id, string uid, string name, IStopwatch stopwatch) => _testNodeProgressStates[uid] = new TestDetailState(id, stopwatch, name); | ||
|
|
||
| public void RemoveRunningTestNode(string uid) => _testNodeProgressStates.TryRemove(uid, out _); | ||
|
|
||
| public TestDetailState? GetFirstRunningTask() => _testNodeProgressStates.FirstOrDefault().Value; | ||
|
|
||
| public IEnumerable<TestDetailState> GetRunningTasks(int maxCount) | ||
| { | ||
| var sortedDetails = _testNodeProgressStates | ||
| .Select(d => d.Value) | ||
| .OrderByDescending(d => d.Stopwatch?.Elapsed ?? TimeSpan.Zero) | ||
| .ToList(); | ||
|
|
||
| bool tooManyItems = sortedDetails.Count > maxCount; | ||
|
|
||
| if (tooManyItems) | ||
| { | ||
| // Note: If there's too many items to display, the summary will take up one line. | ||
| // As such, we can only take maxCount - 1 items. | ||
| int itemsToTake = maxCount - 1; | ||
| _summaryDetail.Text = | ||
| itemsToTake == 0 | ||
| // Note: If itemsToTake is 0, then we only show two lines, the project summary and the number of running tests. | ||
| ? string.Format(CultureInfo.CurrentCulture, PlatformResources.ActiveTestsRunning_FullTestsCount, sortedDetails.Count) | ||
| // If itemsToTake is larger, then we show the project summary, active tests, and the number of active tests that are not shown. | ||
| : $"... {string.Format(CultureInfo.CurrentCulture, PlatformResources.ActiveTestsRunning_MoreTestsCount, sortedDetails.Count - itemsToTake)}"; | ||
| sortedDetails = sortedDetails.Take(itemsToTake).ToList(); | ||
| } | ||
|
|
||
| foreach (TestDetailState? detail in sortedDetails) | ||
| { | ||
| yield return detail; | ||
| } | ||
|
|
||
| if (tooManyItems) | ||
| { | ||
| yield return _summaryDetail; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.