-
Notifications
You must be signed in to change notification settings - Fork 985
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
Fix test decorations #3064
Fix test decorations #3064
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.
I think we discussed this before and as far as I remember I verified that TestData is automatically disposed by xunit, as such you don't have to manually dispose things you get passed as arguments from TestData.
src/System.Windows.Forms/tests/UnitTests/BindingNavigatorTests.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ControlBindingsCollectionTests.cs
Outdated
Show resolved
Hide resolved
...tests/UnitTests/System/Windows/Forms/DataGridViewCellContextMenuStripNeededEventArgsTests.cs
Outdated
Show resolved
Hide resolved
...Windows.Forms/tests/UnitTests/System/Windows/Forms/DataGridViewCellPaintingEventArgsTests.cs
Outdated
Show resolved
Hide resolved
...orms/tests/UnitTests/System/Windows/Forms/DataGridViewEditingControlShowingEventArgsTests.cs
Outdated
Show resolved
Hide resolved
I can't recall this, sorry. And this is something I'm trying to work out right now. I know xUnit serialises (certain?) theories to calculate number of tests, that's why it was impossible to public static IEnumerable<object[]> Ctor_Control_DataGridViewCellStyle_TestData()
{
yield return new object[] { null, null };
yield return new object[] { new Button(), new DataGridViewCellStyle() };
}
[WinFormsTheory]
[MemberData(nameof(Ctor_Control_DataGridViewCellStyle_TestData))]
public void Ctor_Control_DataGridViewCellStyle(Control control, DataGridViewCellStyle cellStyle)
{
var e = new DataGridViewEditingControlShowingEventArgs(control, cellStyle);
Assert.Equal(control, e.Control);
Assert.Equal(cellStyle, e.CellStyle);
control?.Dispose();
} Here's I know that there are no more uses for the public static IEnumerable<object[]> Ctor_Control_DataGridViewCellStyle_TestData()
{
yield return new object[] { null, null };
var button = new Button();
yield return new object[] { button, new DataGridViewCellStyle() };
yield return new object[] { button { Text = "bla" }, new DataGridViewCellStyle() };
} I wouldn't be able to dispose it in the test, because it would affect the 3rd theory data. |
It was in a PR discussion where it was unclear whether test data needs to be disposed, github doesn't seem to search PR comments so I can't find it again easily, sorry. It was mostly me checking that theory arguments are disposed by design and linking the xunit source which is doing that.
They just check for IDisposable here and disposal happens here. I'm checking for it by making a theory argument disposable and putting a breakpoint into it, then running the test under the debugger.
By disposing after running the whole set (and not after each individual test data) they don't have to bother with objects shared across test data. They may call Dispose multiple times on the same object, but that shouldn't hurt since Dispose by design should tolerate multiple calls.
I didn't test disposal under serialization conditions so I don't know how this behaves. However when controls are part of the theory data it would probably just fail because those are not serializable, even though they are MarshalByRef this only should work on Desktop Framework, .NET Core does not support remoting as far as I'm aware. So I wouldn't bother too much, only primitives like strings can be serialized, any complex disposable object will just cause failure and not leak. If I remember right serialization happens when running tests from VS (which is why you can't just execute all tests in VS but have to select individual ones, since some of the external test runner objects are not serializable). I don't know if its the same serialization you are talking of, there were several different serialization problems, and they may be unrelated. |
I had a chat with @bradwilson and he confirmed the same (implementation and test). However a new interesting discovery came out as well, that bothered me for a while. public static IEnumerable<object[]> Ctor_Control_DataGridViewCellStyle_TestData()
{
var button = new Button();
yield return new object[] { button, new DataGridViewCellStyle() };
yield return new object[] { button { Text = "bla" }, new DataGridViewCellStyle() };
} Brad stated that this code is strictly speaking not legal, and may lead to undefined behaviours. Which means we'll need to remediate the existing code. /cc: @hughbe @M-Lipin @vladimir-krestov FYI |
b489c2b
to
3d38347
Compare
1867275
to
cc7ee35
Compare
7c05626
to
465928f
Compare
de1b201
to
f6e2d3b
Compare
5638015
to
eee5abf
Compare
Will this fix the hundreds of tests that occasionally fail E.g. https://dev.azure.com/dnceng/public/_build/results?buildId=628388&view=ms.vss-test-web.build-test-results-tab |
I'm expecting to have a more stable test phase. Right now a lot of tests fail because we're running out of available handles 😱
However I'm observing some additional instabilities that I'm yet to identify - there are too many moving parts - we moved to a different build pool, different build image, updates from the runtime and the arcade, updates to the tests, etc... |
93aa46b
to
408c115
Compare
601c883
to
c6704c5
Compare
Looks like we had another big deadlock issue with |
Codecov Report
@@ Coverage Diff @@
## master #3064 +/- ##
====================================================
- Coverage 61.66307% 32.77630% -28.88677%
====================================================
Files 1288 866 -422
Lines 451935 254086 -197849
Branches 39511 36748 -2763
====================================================
- Hits 278677 83280 -195397
+ Misses 167869 166007 -1862
+ Partials 5389 4799 -590
|
Microsoft Reviewers: Open in CodeFlow