58ed2604af
Directory.current.path on Windows uses "\" and not "/" and does not start with a slash. Bug: Change-Id: Id1b75ee0e3962c3531ba964aee9300025cdbcdca Reviewed-on: https://dart-review.googlesource.com/34101 Reviewed-by: Jens Johansen <jensj@google.com>
34 lines
1.3 KiB
Dart
Executable File
34 lines
1.3 KiB
Dart
Executable File
import 'dart:io';
|
|
import 'package:expect/minitest.dart';
|
|
import 'package:dev_compiler/src/kernel/command.dart';
|
|
|
|
main(List<String> args) {
|
|
// Various URL schemes
|
|
expect(stringToUri("dart:io").toString(), "dart:io");
|
|
expect(stringToUri("package:expect/minitest.dart").toString(),
|
|
"package:expect/minitest.dart");
|
|
expect(stringToUri("foobar:whatnot").toString(), "foobar:whatnot");
|
|
|
|
// Full Windows path
|
|
expect(stringToUri("C:\\full\\windows\\path.foo", windows: true).toString(),
|
|
"file:///C:/full/windows/path.foo");
|
|
expect(stringToUri("C:/full/windows/path.foo", windows: true).toString(),
|
|
"file:///C:/full/windows/path.foo");
|
|
|
|
// Get current dir, making sure we use "/" and start with "/".
|
|
String currentDir = Directory.current.path.replaceAll(r'\', r'/');
|
|
if (!currentDir.startsWith(r'/')) currentDir = "/$currentDir";
|
|
|
|
// Relative Windows path
|
|
expect(stringToUri("partial\\windows\\path.foo", windows: true).toString(),
|
|
"file://$currentDir/partial/windows/path.foo");
|
|
|
|
// Full Unix path
|
|
expect(stringToUri("/full/path/to/foo.bar", windows: false).toString(),
|
|
"file:///full/path/to/foo.bar");
|
|
|
|
// Relative Unix path
|
|
expect(stringToUri("partial/path/to/foo.bar", windows: false).toString(),
|
|
"file://$currentDir/partial/path/to/foo.bar");
|
|
}
|