Do not lower-case paths during canonicalization. (#9571)

* Do not lower-case paths during canonicalization.

This breaks hot reload on some platfroms with case insensitive file systems.

* Add unit tests
This commit is contained in:
Michael Goderbauer
2017-04-25 10:34:43 -07:00
committed by GitHub
parent 31828609dc
commit ad1c497c03
11 changed files with 86 additions and 17 deletions

View File

@@ -59,4 +59,30 @@ void main() {
expect(sourceMemoryFs.directory(sourcePath).listSync().length, 3);
});
});
group('canonicalizePath', () {
test('does not lowercase on Windows', () {
String path = 'C:\\Foo\\bAr\\cOOL.dart';
expect(canonicalizePath(path), path);
// fs.path.canonicalize does lowercase on Windows
expect(fs.path.canonicalize(path), isNot(path));
path = '..\\bar\\.\\\\Foo';
final String expected = fs.path.join(fs.currentDirectory.parent.absolute.path, 'bar', 'Foo');
expect(canonicalizePath(path), expected);
// fs.path.canonicalize should return the same result (modulo casing)
expect(fs.path.canonicalize(path), expected.toLowerCase());
}, testOn: 'windows');
test('does not lowercase on posix', () {
String path = '/Foo/bAr/cOOL.dart';
expect(canonicalizePath(path), path);
// fs.path.canonicalize and canonicalizePath should be the same on Posix
expect(fs.path.canonicalize(path), path);
path = '../bar/.//Foo';
final String expected = fs.path.join(fs.currentDirectory.parent.absolute.path, 'bar', 'Foo');
expect(canonicalizePath(path), expected);
}, testOn: 'posix');
});
}