Skip to content

Commit 81cb17e

Browse files
sstricklCommit Queue
authored andcommitted
[io/win] Allow notFound stat errors in testDriveLetterNoBackslash.
Since the test uses existing system temp directory entries that aren't created/maintained by the test itself, they may be removed between the two calls to statSync(). Modify the test to allow for cases where the first statSync() returns a non-notFound result and the second returns a notFound result. Also check that at least one iteration of the loop had a successful result where the statSync() result is the same for both and was not a notFound result, as all system temp entries retrieved by listSync() being removed before one or both statSync() calls is highly unlikely. TEST=standalone/io/file_windows_test Fixes: #61007 Cq-Include-Trybots: luci.dart.try:vm-win-release-x64-try Change-Id: If4bb4a6f6b1e21558e447e4e5a918523c69ff044 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437442 Commit-Queue: Tess Strickland <[email protected]> Reviewed-by: Johnni Winther <[email protected]>
1 parent fb2ada0 commit 81cb17e

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

tests/standalone/io/file_windows_test.dart

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ void testDriveLetterStat() {
2626
// converted refer to the same thing.
2727
void testDriveLetterNoBackslash() {
2828
final current = Directory.current.path;
29+
var allFailed = true;
2930
for (var e in Directory.systemTemp.listSync()) {
3031
final path = e.path;
3132
if (path.length < 3) return;
@@ -40,12 +41,22 @@ void testDriveLetterNoBackslash() {
4041
}
4142
}
4243
noBackslash += path.substring(3);
43-
Expect.equals(
44-
"${Directory(noBackslash).statSync()}",
45-
"${Directory(path).statSync()}",
46-
);
44+
final noBackslashStat = Directory(noBackslash).statSync();
45+
final pathStat = Directory(path).statSync();
46+
if (noBackslashStat.type != pathStat.type) {
47+
// Since these are entries in the system temp directory, they may
48+
// be removed between the two calls.
49+
Expect.notEquals(FileSystemEntityType.notFound, noBackslashStat.type);
50+
Expect.equals(FileSystemEntityType.notFound, pathStat.type);
51+
} else {
52+
Expect.stringEquals(noBackslashStat.toString(), pathStat.toString());
53+
if (noBackslashStat.type != FileSystemEntityType.notFound) {
54+
allFailed = false;
55+
}
56+
}
4757
}
4858
}
59+
Expect.isFalse(allFailed, "no successful statSync() comparisons");
4960
}
5061

5162
void testDeleteLongPathPrefix() {

0 commit comments

Comments
 (0)