Skip to content
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

Make the cancelation can be executed before the task is done #11225

Merged
merged 5 commits into from
Jan 23, 2025

Conversation

GangWang01
Copy link
Member

@GangWang01 GangWang01 commented Jan 6, 2025

Fixes #11018

Context

Test result Shouldly.ShouldAssertException : task.Result\r\n should be\r\nFalse\r\n but was\r\nTrue indicates that the task is done quickly before the cancelation is executed, though the test cancels it right after it is started.

Changes Made

Make a fake stream that provides a single character A~Z per a couple of milliseconds infinitely without high memory cost as the content of http response message and increase the task timeout a little so that the cancellation can be executed.

Testing

N/A

Notes

@GangWang01 GangWang01 force-pushed the downloadfile-flaky-test branch from a83e0d4 to bdd4baa Compare January 6, 2025 10:07
@GangWang01
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@GangWang01 GangWang01 marked this pull request as ready for review January 7, 2025 07:36
…f milliseconds without high memory cost instead
@GangWang01 GangWang01 requested a review from SimaTian January 17, 2025 06:23
SimaTian
SimaTian previously approved these changes Jan 20, 2025
@SimaTian SimaTian self-requested a review January 20, 2025 13:04
@SimaTian SimaTian dismissed their stale review January 20, 2025 13:04

noticed one more detail

@GangWang01 GangWang01 changed the title Make the file large enough so that the cancelation can be executed before the task is done Make the cancelation can be executed before the task is done Jan 21, 2025
Copy link
Member

@JanKrivanek JanKrivanek left a comment

Choose a reason for hiding this comment

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

Looks good!

Please just make sure the code is understandable to anyone without context as well.

@GangWang01 GangWang01 merged commit 291a810 into dotnet:main Jan 23, 2025
10 checks passed
@GangWang01 GangWang01 deleted the downloadfile-flaky-test branch January 23, 2025 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flaky test - Microsoft.Build.Tasks.UnitTests.DownloadFile_Tests.CanBeCanceled
4 participants