Skip to content

Commit 9a89081

Browse files
committed
Address flakes from using temp directory to run tests
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.
1 parent b61423d commit 9a89081

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

dwds/test/fixtures/project.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,10 @@ class TestProject {
240240
try {
241241
_fixturesCopy.deleteSync(recursive: true);
242242
} on FileSystemException catch (_) {
243+
assert(Platform.isWindows);
243244
// On Windows, the build daemon process might still be accessing the
244-
// working directory, so wait a second and then try again.
245-
await Future.delayed(const Duration(seconds: 1));
245+
// working directory, so wait a few seconds and then try again.
246+
await Future.delayed(const Duration(seconds: 5));
246247
_fixturesCopy.deleteSync(recursive: true);
247248
}
248249
}

test_common/lib/utilities.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ const fixturesDirName = 'fixtures';
1212

1313
const newDdcTypeSystemVersion = '3.3.0-242.0.dev';
1414

15+
final _currentDirectory = p.current;
16+
1517
/// The path to the webdev directory in the local machine, e.g.
1618
/// '/workstation/webdev'.
1719
String get webdevPath {
18-
final pathParts = p.split(p.current);
20+
final pathParts = p.split(_currentDirectory);
1921
assert(pathParts.contains(webdevDirName));
2022
return p.joinAll(
2123
pathParts.sublist(0, pathParts.lastIndexOf(webdevDirName) + 1),

0 commit comments

Comments
 (0)