Skip to content

Commit f40b06a

Browse files
aamCommit Bot
authored andcommitted
[dartdev] Make directory cleanup more resilient on Windows.
Processes on Windows can take longer to exit, taking longer for directories they use to become available for deletion. Accommodate this potentially lengthy by trying several times to delete temp directories before failing the test. Fixes #47700 TEST=run_test on Windows Change-Id: Id73d6ba3ff981ed59c89ab833f5775eff5375ae6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226980 Reviewed-by: Ben Konyi <bkonyi@google.com> Commit-Queue: Alexander Aprelev <aam@google.com>
1 parent 8ba6128 commit f40b06a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

pkg/dartdev/test/utils.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,17 @@ dev_dependencies:
9797
_process?.kill();
9898
await _process?.exitCode;
9999
_process = null;
100-
if (dir.existsSync()) {
101-
dir.deleteSync(recursive: true);
100+
int deleteAttempts = 5;
101+
while (dir.existsSync()) {
102+
try {
103+
dir.deleteSync(recursive: true);
104+
} catch (e) {
105+
if ((--deleteAttempts) <= 0) {
106+
rethrow;
107+
}
108+
await Future.delayed(Duration(milliseconds: 500));
109+
print('Got $e while deleting $dir. Trying again...');
110+
}
102111
}
103112
}
104113

0 commit comments

Comments
 (0)