-
Notifications
You must be signed in to change notification settings - Fork 782
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
Change cancellation test to not depend on how AwaitTask works #7467
Conversation
@matthid I think this test is still testing what you intended it to. |
No, the test was exactly how I intended it ;) |
This test is to check that when an Async is started as a Task (via StartAsTask) that when cancelled the Task isn't immediately marked as cancelled but instead waits for the underlying Async to finish (normally via cancellation)
5b96759
to
75500f1
Compare
Bit sad that it tested both the behaviour of StartAsTask and AwaitTask in the same test. How about now, split into two tests, does that still test what you intended? |
Yes I think they do, though testing those two primitives together is probably fine as they are often used together as well. In any case increasing test coverage is a good thing. |
let innerTcs = new TaskCompletionSource<unit>() | ||
let a = innerTcs.Task |> Async.AwaitTask | ||
|
||
Async.StartWithContinuations(a, tcs.SetResult, tcs.SetException, ignore >> tcs.SetCanceled, cts.Token) |
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 looks a bit bogus to me you await the task here and use setresult as continuation. But if the task finished setresult is already called and the continuation will throw
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.
Ah you have two tcs so this is basically just StartAsTask or very similar
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.
tcs vs innerTcs, this is setting the tcs result, while the task that we AwaitTask on is from innerTcs.
@Frassle, I'm not sure I understand what benefits, this test change achieves. Are you sure you wish to perservere with this PR? |
Prompted by comments on #7357 (which is a PR to fix #2127). It was pointed out that That use of |
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 this contribution.
Kevin
…#7467) * Change cancellation test to not depend on how AwaitTask works This test is to check that when an Async is started as a Task (via StartAsTask) that when cancelled the Task isn't immediately marked as cancelled but instead waits for the underlying Async to finish (normally via cancellation) * Add test that AwaitTask ignore async cancellation
This test is to check that when an Async is started as a Task (via
StartAsTask) that when cancelled the Task isn't immediately marked as
cancelled but instead waits for the underlying Async to finish (normally
via cancellation)
Prompted from comments on #7357.