[testing] Fix path relativization on Windows

Change-Id: Ie685fb3cebf9e9c638c1e82b0f88d1c540c86a98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143810
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
Johnni Winther 2020-04-20 08:21:46 +00:00 committed by commit-bot@chromium.org
parent d690a0c7c4
commit 5a80fb6090

View file

@ -137,8 +137,8 @@ class AnalyzerDiagnostic {
return kind == null
? "Malformed output from dartanalyzer:\n$message"
: "${uri.toFilePath()}:$line:$startColumn: "
"${kind == 'INFO' ? 'warning: hint' : kind.toLowerCase()}:\n"
"[$code] $message";
"${kind == 'INFO' ? 'warning: hint' : kind.toLowerCase()}:\n"
"[$code] $message";
}
}
@ -169,10 +169,18 @@ Future<Null> analyzeUris(
} catch (e) {
topLevel = Uri.base.toFilePath(windows: false);
}
if (Platform.isWindows) {
// We need lowercase comparison on Windows to match C:/path with c:/path
topLevel = topLevel.toLowerCase();
}
String toFilePath(Uri uri) {
String path = uri.toFilePath(windows: false);
return path.startsWith(topLevel) ? path.substring(topLevel.length) : path;
return (Platform.isWindows
? path.toLowerCase().startsWith(topLevel)
: path.startsWith(topLevel))
? path.substring(topLevel.length)
: path;
}
Set<String> filesToAnalyze = new Set<String>();