Skip to content

Commit 6fde533

Browse files
aamCommit Queue
authored andcommitted
[gardening] Fix update_static_error_tests so it works on Windows.
Change-Id: Ie756cb49468f86abece14c1e15706c5a107e21c3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/450801 Commit-Queue: Alexander Aprelev <[email protected]> Reviewed-by: Bob Nystrom <[email protected]>
1 parent b4cd468 commit 6fde533

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

pkg/test_runner/test/update_error_cmdline_test.dart

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,8 @@ Future<void> doTest(List<String> fileNameParts, List<String> testNameParts,
7373
await run(relativeUriPath, target, expectedLines, expectedUpdateText);
7474

7575
var absoluteNativePath = File(relativeNativePath).absolute.path;
76-
var result = await run(
76+
errorFound |= await run(
7777
absoluteNativePath, target, expectedLines, expectedUpdateText);
78-
if (Platform.isWindows) {
79-
// TODO(johnniwinther,rnystrom): Support absolute paths on Windows.
80-
if (!result) {
81-
print('Error: Expected failure on Windows. '
82-
'Update test to expect success on all platforms.');
83-
errorFound = true;
84-
} else {
85-
print('Error on Windows is expected.');
86-
}
87-
} else {
88-
errorFound |= result;
89-
}
9078
}
9179

9280
if (errorFound) {

pkg/test_runner/tool/update_static_error_tests.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,13 @@ List<TestFile> _listFiles(List<String> pathGlobs,
184184
// or relative to the current directory.
185185
var root = pathGlob.startsWith("tests") ? "." : "tests";
186186

187-
// [Glob] doesn't handle Windows path delimiters, so we normalize it using
188-
// [Path]. [Glob] doesn't handle absolute Windows paths, though, so this
189-
// only supports the relative paths.
190-
pathGlob = Path.normalize(pathGlob);
187+
pathGlob = Uri.file(pathGlob).toFilePath(windows: false);
188+
if (Platform.isWindows && p.isAbsolute(pathGlob)) {
189+
// Trim absolute path's leading forward slash on Windows to accommodate
190+
// Glob, which doesn't handle proper backslash-separated Windows paths
191+
// and proper absolute file uri on Windows look like '/c:/abc/temp.txt'.
192+
pathGlob = pathGlob.substring(1);
193+
}
191194

192195
for (var file in Glob(pathGlob, recursive: true).listSync(root: root)) {
193196
if (file is! File) continue;

0 commit comments

Comments
 (0)