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

Add additional System.Threading.Tasks tests - #2775

Merged
stephentoub merged 4 commits into
dotnet:masterfrom
mellinoe:tasks-tests
Aug 14, 2015
Merged

stephentoub merged 4 commits into
dotnet:masterfrom
mellinoe:tasks-tests

Conversation

@mellinoe

Copy link
Copy Markdown
Contributor

I've ported the remainder of our System.Threading.Tasks tests from our internal sources. A lot of these are moved over unchanged (except for porting to xUnit).

Some of the tests were not really designed to be run one after another, and left a lot of "orphaned" tasks doing a whole bunch of work even when the test case finished running. This was causing unpredictable performance, as some test would take a really long time in a "full run", but very little time if run individually, because there were tons of leftover tasks still running. I've attempted to clean those cases up, so that each test case cleans up after the tasks it starts. I have also marked a decent chunk of these tests as OuterLoop because they tend to run for a very long time (some just by their nature, some probably can be optimized if we want to make them inner loop tests).

@stephentoub

I've ported the remainder of our Tasks tests from our internal sources. A
lot of these are moved over unchanged (except for porting to xUnit). Some
of the tests were not really designed to be run one after another, and
left a lot of "orphaned" tasks doing a whole bunch of work even when the
test case finished running. This was causing unpredictable performance, as
some test would take a really long time in a "full run", but very little
time if run individually. I've attempted to clean those cases up, so
that each test case cleans up after the tasks it starts. I have also marked
a decent chunk of these tests as OuterLoop because they tend to run for a
very long time (some just by their nature, some probably can be optimized
if we want to make them inner loop tests).
@mellinoe

Copy link
Copy Markdown
Contributor Author

Fixes #702

@mellinoe

Copy link
Copy Markdown
Contributor Author

@dotnet-bot test this, please

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.

I was about to say that it's strange to have AggregateException tests here rather than in the contract from which AggregateException is exposed... and then I discovered that AggregateException is in fact exposed from System.Threading.Tasks. That's odd, but... oh well.

@stephentoub

Copy link
Copy Markdown
Member

@mellinoe, thanks. There's an enormous amount of code here. At some point I'd like to review it all, but for now I just did a few spot checks to look for any glaring errors. I'm fine with you checking in once CI consistently passes. Note that the current failure that shows on Linux is also reproduceable on Windows... I was able to trigger it a handful of times by running that one test repeatedly (I made it a [Theory] that took a single int parameter and used a MemberData that yielded a thousand integers).

@mellinoe

Copy link
Copy Markdown
Contributor Author

Thanks for the first pass, Stephen. I will check out the flaky test tomorrow and see what is up. That was one of the last files I included so I didn't run those tests as many times as the others.

I'll address the low-hanging fruit you mentioned, like the tests that can obviously be easily converted to [Theory]'s and the bad Assertion styles. I also plan on doing a more thorough cleanup / rewrite of some of these tests next week when I'm TestCop. There's a few things I want to at least accomplish at that time:

  • Convert even more test cases to Theory's when useful
  • Share more code between test cases: There is a lot of code that is duplicated or only slightly different between test classes
  • Improve test speed: The tests are running usually in 5-8 seconds on my machine, but sometimes they will take as long as 30 seconds for some reason. It's probably due to what I described above (test cases leaving tasks running for a long time). It's hard to pinpoint the cause of this.
  • Check out the code coverage numbers and see where to improve coverage

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.

I suppose we do want them now? 😉

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, added back and fixed up

Responding mostly to PR feedback and doing a bit of extra cleanup
There seems to be a potential product issue that needs investigating here.
@stephentoub

Copy link
Copy Markdown
Member

Great that you'll be spending some more time on these next week. In the meantime, as an initial port, LGTM.

stephentoub added a commit that referenced this pull request Aug 14, 2015
Add additional System.Threading.Tasks tests
@stephentoub
stephentoub merged commit d4782cf into dotnet:master Aug 14, 2015
@mellinoe
mellinoe deleted the tasks-tests branch October 7, 2015 18:40
@karelz karelz modified the milestone: 1.0.0-rtm Dec 3, 2016
Assert.ThrowsAsync<ArgumentNullException>(
() => future.ContinueWith<int>((Func<Task<int>, Object, int>)null, null, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.Default));
Assert.ThrowsAsync<ArgumentNullException>(
() => future.ContinueWith<int>((t, s) => 2, null, CancellationToken.None, TaskContinuationOptions.None, null));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ran across these in master. None of these are awaited. Looks like a bug both now and at the time.

"xunit": "2.1.0-beta3-*",

https://github.com/xunit/xunit/blob/2.1-beta3/src/xunit.assert/Asserts/ExceptionAsserts.cs#L50

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.

Ugh. Yeah, that's busted. I'll fix it. Thanks for pointing it out.

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.

7 participants