-
Notifications
You must be signed in to change notification settings - Fork 85
Address flakes from using temp directory to run tests #2649
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
Conversation
dart-lang@2172ba7 added support to run tests in a temporary directory. This results in two flaky issues: 1. On Windows, build_daemon tests may fail to delete the temp directory because the process may have not been torn down yet, so it may still be accessing the file system. There was an initial retry after 1 second, but that appears to be not enough looking at a recent test run. 2. If a test times out, its tearDown may not be called. In this case, the ResidentWebRunner in frontend_server may not restore the current directory in the LocalFileSystem. This leads to cascading failures in subsequent tests due to no longer being in a path that contains 'webdev'. See https://github.com/dart-lang/webdev/actions/runs/15989286213/job/45099373212?pr=2641 for an example. See dart-lang/test#897 as well for tracking work to call tearDown on timeouts. To address the above issues: 1. Increase the delay between the two tries and assert this only occurs on Windows. 2. Cache the current directory so that it can be used in utilities.dart with the same (correct) value every time.
Looks like we still see an existing failure on the unit_test; windows; Dart dev; PKG: webdev; |
Indeed, that's failing in the CI already and will require a separate PR: https://github.com/dart-lang/webdev/actions/runs/16243343947/job/45862639306 |
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.
LGTM!
Updating things so we're not changing the CWD is a big improvement. I'm fairly certain this is something that we've been burned by in Flutter Tools tests since there's a warning if you try to change the CWD in a test.
Windows is a PITA when it comes to cleaning up resources after a test. As long as we don't crash or cause the test to fail, it's fine to occasionally leak these resources since they'll only persist as long as the container is alive anyway.
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 the stability improvements!
Indeed, and even with this PR, we're not guaranteed to free up the temp directory (as seen in the logs). But hopefully this reduces the number of instances where this occurs. Thanks for the reviews! |
2172ba7 added support to run tests in a temporary directory.
This results in two flaky issues:
temp directory because the process may have not been torn
down yet, so it may still be accessing the file system.
There was an initial retry after 1 second, but that appears
to be not enough looking at a recent test run. See https://github.com/dart-lang/webdev/actions/runs/16157459808/job/45602784802?pr=2649
for an example. It's printed as a warning.
relies on modifying the current directory via
dart:io
. Without a tearDown,it never restores the directory the process was in. This
leads to cascading failures in subsequent tests due to it no
longer being in a path that contains 'webdev'. See
https://github.com/dart-lang/webdev/actions/runs/15989286213/job/45099373212?pr=2641
for an example. See tearDown is not called if a test times out test#897
as well for tracking work to call tearDown on timeouts.
To address the above issues: