Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Clean up System.Drawing.Common unit tests - #38771

Merged
stephentoub merged 19 commits into
dotnet:masterfrom
CoreCompat:fixes/drawing-linear-gradient-brush-tests-using
Jun 24, 2019
Merged

stephentoub merged 19 commits into
dotnet:masterfrom
CoreCompat:fixes/drawing-linear-gradient-brush-tests-using

Conversation

@qmfrederik

@qmfrederik qmfrederik commented Jun 22, 2019 •

Copy link
Copy Markdown
  • A lot of the types in System.Drawing.Common implement IDisposable and use native resources. Make sure these types are wrapped in a using statement in the unit tests.
  • Convert BitmapTests.Rotate1bit4bit to a theory, and prevent it from using /tmp directly
  • Convert ScaleTransform_ZeroZero_ThrowsArgumentException and SurroundColors_Null_ThrowsArgumentNullException from a theory to a fact (they have no test parameters)

@stephentoub

stephentoub commented Jun 22, 2019 •

Copy link
Copy Markdown
Member

@qmfrederick, thanks for the PRs, but I'd prefer so many commits all doing the same thing just in different tests don't clutter commit history. Can you please combine them into a single PR? I'm going to close the others and you can cherry-pick them into this one. Thanks.

@qmfrederik

Copy link
Copy Markdown
Author

@stephentoub Sure, I'll get the commits in a single PR.

The tests are still a bit finicky (running them all on macOS causes the test process to abort, apparently because of an exception in a finalizer). I'd like to get a clear indication on which set of changes may cause a regression, and running the tests locally only covers one of the many OS configurations. Hence the smaller PRs. Having the CI run in parallel speeds up things.

I'll cherry-pick the 'green' PRs into this one, re-open the PRs failing CI until they are stable, and then cherry-pick them into this PR. Hope that works for you.

@qmfrederik

Copy link
Copy Markdown
Author

So it turns out that except for one, all other PRs failed because of CI flakes. So that simplifies things 😄 .

@qmfrederik qmfrederik changed the title LinearGradientBrushTests: Add missing using statements Clean up System.Drawing.Common unit tests Jun 22, 2019
@stephentoub

Copy link
Copy Markdown
Member

Thanks, @qmfrederik!

This test was previously disabled (because it was incorrectly marked as a theory instead of a fact).

This is the current behavior on NetFX.

[ConditionalTheory(Helpers.IsDrawingSupported)]
public void SurroundColors_Null_ThrowsArgumentNullException()
[ConditionalFact(Helpers.IsDrawingSupported)]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI @ViktorHofer, as this will conflict with your xunit test cleanup.

@stephentoub stephentoub left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for cleaning all this up. A few comments to be addressed, but otherwise LGTM.

@stephentoub
stephentoub merged commit 8ede3e8 into dotnet:master Jun 24, 2019
@karelz karelz added this to the 3.0 milestone Jul 16, 2019
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* LinearGradientBrushTests: Add missing using statements

* EncoderParametersTests: Add missing using statements

* EncoderParametertests: Additional using statements

* GraphicsPathTests: Add using statements

* Add missing using statements

* RegionTests: Add missing using statements

* Fix typo

* MatrixTests: Add using statements

* GraphicsTests: Add missing using statements

* Fix ConditionalTheory -> ConditionalFact

* Clone the clip before applying a transform

* Convert Rotate1bit4bit to a theory

* SurroundColors_Null_ThrowsArgumentNullException: Theory -> Fact

* Check for a NullReferenceException instead of an ArgumentNullException

This test was previously disabled (because it was incorrectly marked as a theory instead of a fact).

This is the current behavior on NetFX.

* No parameter name to validate

* Don't use statics for disposed objects

* Invoke the finalizer during the test

* PR feedback

* PR feedback


Commit migrated from dotnet/corefx@8ede3e8
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants