Files
sdk/pkg/dev_compiler/test/string_to_uri_test.dart
T
Jens Johansen 58ed2604af Fixup DDC test on Windows (attepmt #2)
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>
2018-01-11 08:06:21 +00:00

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");
}