-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Tests ran counter #111145
base: main
Are you sure you want to change the base?
Tests ran counter #111145
Conversation
Tagging subscribers to this area: @dotnet/gc |
@@ -22,6 +22,7 @@ | |||
using System.Linq; | |||
|
|||
using System.Runtime.Loader; | |||
using Microsoft.CodeAnalysis.CSharp.Syntax; |
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.
I don't think this is needed
public void RecordTestRanCount() | ||
{ | ||
StringBuilder sb = new(); | ||
foreach(var item in _testRanCounter) |
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.
When called via the CancelKeyPress
event, the test will still be running while this code executes. Use _testRanCounterLock here.
if (!_testRanCounter.Keys.Contains(testRefOrID)) | ||
{ | ||
_testRanCounter[testRefOrID] = 0; | ||
} | ||
_testRanCounter[testRefOrID] ++; |
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.
(purely a style comment)
You can use _testRanCounter[testRefOrId] = _testRanCounter.GetValueOrDefault(testRefOrId, 0) + 1
(you can even leave off the 0
and use the other GetValueOrDefault
overload since 0
is the default
value for uint
)
sb.AppendLine($"{item.Key}: {item.Value}"); | ||
} | ||
} | ||
_logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.StartupShutdown, $"Tests ran count:\n{sb}"); |
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: Tests run* count
.
@@ -161,6 +163,11 @@ public static int Main(string[] args) | |||
|
|||
ReliabilityFramework rf = new ReliabilityFramework(); | |||
rf._logger.WriteToInstrumentationLog(null, LoggingLevels.StartupShutdown, "Started"); | |||
|
|||
Console.CancelKeyPress += (object sender, ConsoleCancelEventArgs args) => { |
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: Since you aren't using either of the parameters of the delegate, you could easily set them to _
to indicate that they aren't used i.e.,
csharp Console.CancelKeyPress += (object _, ConsoleCancelEventArgs _) => { .. }
@@ -314,6 +321,19 @@ public static int Main(string[] args) | |||
return (retVal); | |||
} | |||
|
|||
public void RecordTestRanCount() |
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: The name RecordTestRunCount
seems more apt.
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.
LGTM!
Record how many times each test ran for. (even if the run is terminated manually)