-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Delete unnecessary seek from FileStream.SetLengthInternal on Unix #44097
Conversation
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.
Looks good to me once CI is green. I'm trying to remember why all this was deemed necessary and coming up empty.
I suspect that it was just copy&paste from Windows where we can avoid it as well - #43863 (comment). |
|
@@ -112,7 +112,7 @@ public void TooLargeCapacity_Unix() | |||
// due to differences in OS behaviors and Unix not actually having a notion of | |||
// a view separate from a map. It could also come from CreateNew, depending | |||
// on what backing store is being used. | |||
Assert.Throws<IOException>(() => | |||
AssertExtensions.ThrowsAny<IOException, ArgumentException>(() => |
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.
It looks like this method is poorly named, in that whereas Assert.ThrowsAny<T>
allows for the exception to be T or anything derived from it, AssertExtensions.ThrowsAny<T1, T2>
is requiring the concrete type of T1 or T2:
runtime/src/libraries/Common/tests/TestUtilities/System/AssertExtensions.cs
Lines 195 to 216 in 22c3105
public static void ThrowsAny(Type firstExceptionType, Type secondExceptionType, Action action) | |
{ | |
ThrowsAnyInternal(action, firstExceptionType, secondExceptionType); | |
} | |
private static void ThrowsAnyInternal(Action action, params Type[] exceptionTypes) | |
{ | |
try | |
{ | |
action(); | |
} | |
catch (Exception e) | |
{ | |
Type exceptionType = e.GetType(); | |
if (exceptionTypes.Any(t => t.Equals(exceptionType))) | |
return; | |
throw new XunitException($"Expected one of: ({string.Join<Type>(", ", exceptionTypes)}) -> Actual: ({exceptionType})"); | |
} | |
throw new XunitException($"Expected one of: ({string.Join<Type>(", ", exceptionTypes)}) -> Actual: No exception thrown"); | |
} |
which is then failing if the exception is actually an ArgumentOutOfRangeException.
ae6acc1
to
5901a0c
Compare
Also, improve test coverage for FileStream.SetLength
ec6d800
to
4ae2738
Compare
No description provided.