From 8a70d3e4040b2b1ae02b585dedb620eac9e3fdb5 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Mon, 8 Aug 2016 16:23:50 -0700 Subject: [PATCH] Fix current_isolate_info_test. This test didn't actually work when run with a package root rather than a package config, as is the case in Google-internal tests. R=jmesserly@google.com Review URL: https://codereview.chromium.org//2224203002 . --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- test/current_isolate_info_test.dart | 24 ++++++++++++++++++------ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b26ad3..c280641 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.1 + +* Internal changes only. + ## 1.0.0 * Initial version. diff --git a/pubspec.yaml b/pubspec.yaml index d33cd97..de2c1bb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: package_resolver -version: 1.0.0 +version: 1.0.1 description: First-class package resolution strategy classes. author: Dart Team homepage: https://github.com/dart-lang/package_resolver diff --git a/test/current_isolate_info_test.dart b/test/current_isolate_info_test.dart index bb6f4f7..5da0ff4 100644 --- a/test/current_isolate_info_test.dart +++ b/test/current_isolate_info_test.dart @@ -12,6 +12,7 @@ import 'package:stack_trace/stack_trace.dart'; import 'package:test/test.dart'; import 'package:package_resolver/package_resolver.dart'; +import 'package:package_resolver/src/utils.dart'; void main() { // It's important to test these, because they use PackageConfig.current and @@ -38,12 +39,12 @@ void main() { } else { // If the isolate running this test isn't using package config, create // one from scratch with the same resolution semantics. - var map = {}; + map = {}; var root = p.fromUri(await PackageResolver.current.packageRoot); await for (var link in new Directory(root).list(followLinks: false)) { assert(link is Link); map[p.basename(link.path)] = - p.toUri(await link.resolveSymbolicLinks()); + ensureTrailingSlash(p.toUri((await link.resolveSymbolicLinks()))); } } @@ -188,11 +189,22 @@ void main() { }); } -Future get _packageResolverLibUri async => - (await PackageResolver.current.urlFor("package_resolver")).toString(); +Future get _packageResolverLibUri => _urlForPackage('package_resolver'); -Future get _pathLibUri async => - (await PackageResolver.current.urlFor("path")).toString(); +Future get _pathLibUri => _urlForPackage('path'); + +Future _urlForPackage(String package) async { + var uri = await PackageResolver.current.urlFor(package); + if (await PackageResolver.current.packageConfigMap != null) { + return uri.toString(); + } + + // If we're using a package root, we resolve the symlinks in the test code so + // we need to resolve them here as well to ensure we're testing against the + // same values. + var resolved = new Directory(p.fromUri(uri)).resolveSymbolicLinksSync(); + return ensureTrailingSlash(p.toUri(resolved)).toString(); +} Future _spawn(String expression, PackageResolver packageResolver) async { var data = new UriData.fromString("""