-
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] Fix integer rounding error in GetTestFileName #52266
Conversation
Tagging subscribers to this area: @carlossanlop |
@@ -102,7 +102,9 @@ protected string GetTestFileName(int? index = null, [CallerMemberName] string me | |||
if (excessLength < memberName.Length + "...".Length) | |||
{ | |||
// Take a chunk out of the middle as perhaps it's the least interesting part of the name | |||
memberName = memberName.Substring(0, memberName.Length / 2 - excessLength / 2) + "..." + memberName.Substring(memberName.Length / 2 + excessLength / 2); | |||
int halfMemberNameLength = (int)Math.Floor((double)memberName.Length / 2); | |||
int halfExcessLength = (int)Math.Floor((double)excessLength / 2); |
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.
This should probably be Ceil not Floor, and then we don't need the +1 on the math.
src/libraries/Common/tests/TestUtilities/System/IO/FileCleanupTestBase.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/tests/TestUtilities/System/IO/FileCleanupTestBase.cs
Outdated
Show resolved
Hide resolved
Hello @danmoseley! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
Fixes #52257
There seemed to be an integer rounding error when getting a portion of the test file name. Using the suggestion #52257 (comment) led to the tests running to completion with no crashes or hangs.