Fix packages_file_test on OS X.
OS X symlinks its /tmp directory, so we need to resolve symlinks before
we can safely compare paths that might include /tmp.
Review URL: https://codereview.chromium.org//1225483003.
diff --git a/test/descriptor.dart b/test/descriptor.dart
index a9c5dff..4a0a62b 100644
--- a/test/descriptor.dart
+++ b/test/descriptor.dart
@@ -192,7 +192,10 @@
/// Describes a `.packages` file.
///
-/// [dependencies] maps package names to version strings.
+/// [dependencies] maps package names to strings describing where the packages
+/// are located on disk. If the strings are sematnic versions, then the packages
+/// are located in the system cache; otherwise, the strings are interpreted as
+/// relative `file:` URLs.
///
/// Validation checks that the `.packages` file exists, has the expected
/// entries (one per key in [dependencies]), each with a path that contains
diff --git a/test/descriptor/packages.dart b/test/descriptor/packages.dart
index 5fbdb28..9d857c0 100644
--- a/test/descriptor/packages.dart
+++ b/test/descriptor/packages.dart
@@ -23,14 +23,15 @@
new RegExp(r"^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)"
r"(?:-[a-zA-Z\d-]+)?(?:\+[a-zA-Z\d-]+)?$");
- final _dependencies;
+ /// A map from package names to strings describing where the packages are
+ /// located on disk.
+ final Map<String, String> _dependencies;
/// Describes a `.packages` file with the given dependencies.
///
- /// Dependencies maps package name to semantic version.
- PackagesFileDescriptor([Map<String, String> dependencies])
- : _dependencies = dependencies,
- super('.packages');
+ /// [dependencies] maps package names to strings describing where the packages
+ /// are located on disk.
+ PackagesFileDescriptor([this._dependencies]) : super('.packages');
Future create([String parent]) => schedule(() {
if (parent == null) parent = defaultRoot;
@@ -45,7 +46,7 @@
} else {
// Otherwise it's a path relative to the .pubspec file,
// which is also the relative path wrt. the .packages file.
- packagePath = version;
+ packagePath = p.fromUri(version);
}
mapping[package] = p.toUri(p.join(packagePath, "lib", ""));
});
@@ -80,19 +81,22 @@
if (!map.containsKey(package)) {
fail(".packages does not contain $package entry");
}
- var version = _dependencies[package];
- if (_semverRE.hasMatch(version)) {
- if (!map[package].path.contains(version)) {
+
+ var description = _dependencies[package];
+ if (_semverRE.hasMatch(description)) {
+ if (!map[package].path.contains(description)) {
fail(".packages of $package has incorrect version. "
- "Expected $version, found location: ${map[package]}.");
+ "Expected $description, found location: ${map[package]}.");
}
} else {
- var packagePath = fileUri.resolve("$version/lib/");
- if (!packagePath.path.endsWith('/')) {
- packagePath = packagePath.replace(path: packagePath.path + '/');
- }
- if ("${map[package]}" != "$packagePath") {
- fail("Relative path: Expected $packagePath, found ${map[package]}");
+ var expected = p.normalize(p.join(
+ p.dirname(fullPath), p.fromUri(description), 'lib'));
+ expected = new File(expected).resolveSymbolicLinksSync();
+ var actual = new File(p.normalize(p.absolute(p.fromUri(map[package]))))
+ .resolveSymbolicLinksSync();
+
+ if (expected != actual) {
+ fail("Relative path: Expected $description, found ${map[package]}");
}
}
}