-
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
Enable xunit1024 #34512
Enable xunit1024 #34512
Conversation
The very next method is a Theory with inline data that tests this exact scenario.
Looks like there are some more instances to fix, in different configurations. |
This is only fixing occurrences in System.Text.Json. Presumably there are others in many other test projects? Or is Json really the only one? |
src/libraries/System.Text.Json/tests/Utf8JsonReaderTests.TryGet.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.Json/tests/Utf8JsonReaderTests.TryGet.cs
Outdated
Show resolved
Hide resolved
Right, I've only looked at netcoreapp, I'll address net472 hopefully during the weekend.
I was expecting to find more, and my intention with the PR was to fix them all... but I just rebuilt all of the libraries subcategory after fixing |
Nvm, I built the libraries themselves, not their test projects, which are the ones with issues; now I'm seeing more errors. So yeah, I'll keep working on the rest of the test projects. |
For RemoveNonExistingTest, just moved the logic from the single-use helper into the method with the Fact attribute.
In Math.cs, removed Round_Decimal_Digits Fact which manually tested cases included in the MemberData of a Theory with the same name.
Theory EndInit_ResumesPausedEnableRaisingEvents alredy tests the same scenario as the removed Fact of the same name.
@@ -662,7 +662,7 @@ public static IEnumerable<object[]> RoundtripCompressDecompressOuterData | |||
} | |||
|
|||
[Fact] | |||
public async Task CompressDecompress_RoundTrip() | |||
public async Task CompressDecompress_RoundTrip_BaseTests() |
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'd prefer to see this test's name left as-is, and the method it delegates to instead be renamed to something like CompressDecompress_RoundTrip_OuterLoop. Same goes for the other similar cases here. My reason is "BaseTests" doesn't really speak to what the test is doing, plus this is the test that runs 99% of the time, and the one it delegates to is relegated to only running when we run "OuterLoop".
@@ -1666,7 +1666,7 @@ public static void MakeSureNoSequenceEqualChecksGoOutOfRange_Char() | |||
[InlineData("Hello", "llo" + SoftHyphen, StringComparison.OrdinalIgnoreCase, false)] | |||
[InlineData("", "", StringComparison.OrdinalIgnoreCase, true)] | |||
[InlineData("", "a", StringComparison.OrdinalIgnoreCase, false)] | |||
public static void EndsWith(string s, string value, StringComparison comparisonType, bool expected) | |||
public static void EndsWith_ExplicitComparisonType(string s, string value, StringComparison comparisonType, bool expected) |
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.
public static void EndsWith_ExplicitComparisonType(string s, string value, StringComparison comparisonType, bool expected) | |
public static void EndsWith_StringComparison(string s, string value, StringComparison comparisonType, bool expected) |
@@ -4639,7 +4639,7 @@ public void Replace_EmptyOldValue_ThrowsArgumentException() | |||
[InlineData("Hello", SoftHyphen + "Hel", StringComparison.OrdinalIgnoreCase, false)] | |||
[InlineData("", "", StringComparison.OrdinalIgnoreCase, true)] | |||
[InlineData("", "hello", StringComparison.OrdinalIgnoreCase, false)] | |||
public static void StartsWith(string s, string value, StringComparison comparisonType, bool expected) | |||
public static void StartsWith_WithExplicitComparisonType(string s, string value, StringComparison comparisonType, bool expected) |
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.
public static void StartsWith_WithExplicitComparisonType(string s, string value, StringComparison comparisonType, bool expected) | |
public static void StartsWith_StringComparison(string s, string value, StringComparison comparisonType, bool expected) |
@@ -5222,7 +5222,7 @@ public static void LengthMismatchToLower() | |||
} | |||
|
|||
[Fact] | |||
public static void ToLower() | |||
public static void ToLower_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.
What is the other ToLower test this is conflicting with? "ToLower_2" isn't descriptive about what makes this test different from a presumed "ToLower_1", so we should either pick descriptive names or combine the tests.
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's this one, using string
s + Span
instead of char[]
+ Span
throughout. How about naming them ToLower_String
and ToLower_CharArray
?
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.
How about naming them ToLower_String and ToLower_CharArray?
Sounds fine. Thanks.
@@ -5434,7 +5434,7 @@ public static void LengthMismatchToUpper() | |||
} | |||
|
|||
[Fact] | |||
public static void ToUpper() | |||
public static void ToUpper_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.
Ditto
...raries/System.Collections.Concurrent/tests/ConcurrentDictionary/ConcurrentDictionaryTests.cs
Show resolved
Hide resolved
@@ -838,7 +838,7 @@ public static IEnumerable<object[]> EnumeratorTraversalNullData() | |||
|
|||
[Theory] | |||
[MemberData(nameof(EqualsData))] | |||
public void Equals(ImmutableArray<int> first, ImmutableArray<int> second, bool expected) | |||
public void EqualsBaseTest(ImmutableArray<int> first, ImmutableArray<int> second, bool expected) |
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.
Elsewhere you used EqualsTest. Why EqualsBaseTest 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.
I thought it had been because of some class that inherited from this and had its own EqualsTest
, but apparently it's not the case here, I'll simplify to EqualsTest
.
src/libraries/System.Collections.Immutable/tests/ImmutableSetTest.cs
Outdated
Show resolved
Hide resolved
@@ -107,6 +107,7 @@ public void Ctor_LargeSkipFramesFNeedFileInfo_GetFramesReturnsEmpty(bool fNeedFi | |||
[Fact] | |||
public void Ctor_ThrownException_GetFramesReturnsExpected() | |||
{ | |||
// TODO: is this test redundant? See Ctor_ThrownException_GetFramesReturnsExpected_2 below |
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's not redundant, it's testing a different StackTrace constructor.
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.
Good point, I'll remove the comment
@@ -124,7 +125,7 @@ public void Ctor_EmptyException_GetFramesReturnsEmpty() | |||
[Theory] | |||
[InlineData(true)] | |||
[InlineData(false)] | |||
public void Ctor_ThrownException_GetFramesReturnsExpected(bool fNeedFileInfo) | |||
public void Ctor_ThrownException_GetFramesReturnsExpected_2(bool fNeedFileInfo) |
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.
public void Ctor_ThrownException_GetFramesReturnsExpected_2(bool fNeedFileInfo) | |
public void Ctor_Bool_ThrownException_GetFramesReturnsExpected(bool fNeedFileInfo) |
src/libraries/System.Drawing.Common/tests/mono/System.Drawing/GraphicsTests.cs
Show resolved
Hide resolved
@@ -279,7 +279,7 @@ public static IEnumerable<object[]> MemberData_FileStreamAsyncWriting() | |||
} | |||
|
|||
[Fact] | |||
public Task ManyConcurrentWriteAsyncs() | |||
public Task ManyConcurrentWriteAsyncs_BaseTest() |
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.
Same feedback as in a previous similar case... let's leave this one as ManyConcurrentWriteAsyncs, and change the one below to ManyConcurrentWriteAsyncs_OuterLoop.
@@ -59,7 +59,7 @@ public static IEnumerable<object[]> TestData() | |||
|
|||
[Theory] | |||
[MemberData(nameof(TestData))] | |||
public void Any(IEnumerable<int> source, bool expected) | |||
public void AnyTest(IEnumerable<int> source, bool expected) |
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 stay Any
, and the test below should be changed to be Any_Predicate
, or something like that.
@@ -200,7 +200,7 @@ public static void Contains(string s, char value, bool expected) | |||
[InlineData("Hello", 'e', StringComparison.OrdinalIgnoreCase, true)] | |||
[InlineData("Hello", 'E', StringComparison.OrdinalIgnoreCase, true)] | |||
[InlineData("", 'H', StringComparison.OrdinalIgnoreCase, false)] | |||
public static void Contains(string s, char value, StringComparison comparisionType, bool expected) | |||
public static void Contains_Char_ExplicitComparisonType(string s, char value, StringComparison comparisionType, bool expected) |
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.
public static void Contains_Char_ExplicitComparisonType(string s, char value, StringComparison comparisionType, bool expected) | |
public static void Contains_Char_StringComparison(string s, char value, StringComparison comparisionType, bool expected) |
@@ -272,7 +272,7 @@ public static void Contains(string s, char value, StringComparison comparisionTy | |||
[InlineData("Hello", "", StringComparison.OrdinalIgnoreCase, true)] | |||
[InlineData("Hello", "ell" + SoftHyphen, StringComparison.OrdinalIgnoreCase, false)] | |||
[InlineData("Hello", "Ell" + SoftHyphen, StringComparison.OrdinalIgnoreCase, false)] | |||
public static void Contains(string s, string value, StringComparison comparisonType, bool expected) | |||
public static void Contains_String_ExplicitComparisonType(string s, string value, StringComparison comparisonType, bool expected) |
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.
public static void Contains_String_ExplicitComparisonType(string s, string value, StringComparison comparisonType, bool expected) | |
public static void Contains_String_StringComparison(string s, string value, StringComparison comparisonType, bool expected) |
@@ -19,38 +19,38 @@ public class RijndaelTests | |||
[Fact] | |||
public static void VerifyDefaults() | |||
{ | |||
static void verifyDefaults(Rijndael alg) |
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 situations like this, where the test method differs from the local function by the casing of a single letter, it'd be really easy to accidentally get a stack overflow or an infinite loop by calling the wrong thing. Could you rename such local functions to something a little more different?
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.
Sure, I actually started using test
for the local function at some point, I missed updating some of the ones I did earlier.
@@ -1413,9 +1413,12 @@ static void CheckErratum(SignedXml signed, KeyedHashAlgorithm hmac, string messa | |||
} | |||
} | |||
|
|||
private void HmacMustBeMultipleOfEightBits(int bits) | |||
[Fact(Skip = "https://github.com/dotnet/runtime/issues/20429")] |
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: as long as you're changing this, can you make it instead be:
[ActiveIssue("https://github.com/dotnet/runtime/issues/20429")]
[Fact]
?
@@ -997,16 +997,6 @@ public static void ReadKeyValuePairOfList() | |||
Assert.Equal(3, input.Value[2]); | |||
} | |||
|
|||
[Fact] | |||
public static void ReadKeyValuePairOfKeyValuePair() |
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.
Was this a dup? Wondering why it's being deleted.
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.
Yes, see the first bullet point of the second set in the description, there's a Theory testing the exact same thing, and the data that this method uses is already part of the InlineData
of the Theory.
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.
Thanks for cleaning all this up!
The check failures don't seem related to the changes, right? Is it possible to retrigger only the failed builds? |
Thanks! |
There's a couple of recurring patterns in this PR:
Fact
that does nothing but call a helper method with different parameter values, with aTheory
that usesInlineData
(or just "inline" the redundant method, if there was only one call).Fact
/Theory
method, with a local function.I'll make particular notes about changes that do not fall in one of the above patterns, or other comments, for easier review:
src/libraries/System.Text.Json/tests/Serialization/Value.ReadTests.GenericCollections.cs
ReadKeyValuePairOfKeyValuePair
Fact
since theTheory
right after it already covers that case. The code is identical, and the inline data for theTheory
already includes the value that theFact
used.src/libraries/System.Private.Xml/tests/XmlSerialize/XmlSerializerTests.RuntimeOnly.cs
Xml_GuidAsRoot_Helper
andXml_ListGenericRoot_Helper
were just renames, but I noticed that they don't use their only parameter so maybe there's a problem there. To be handled in a separate issue if they actually are.src/libraries/System.Diagnostics.StackTrace/tests/StackTraceTests.cs
Ctor_ThrownException_GetFramesReturnsExpected
might be redundant? Depending on the default value thatfNeedFileInfo
gets when instantiating aStackTrace
, but I couldn't easily find where to check that.Will fix #34503