Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(528)

Unified Diff: lib/src/io.dart

Issue 1153733003: Make the tests work in the Dart repo. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/test_pub.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/io.dart
diff --git a/lib/src/io.dart b/lib/src/io.dart
index 92259fd5ae34c57933b145c9d785d1cb39332505..46ae81a1cea90ae7f2315952402407bb8c8caf93 100644
--- a/lib/src/io.dart
+++ b/lib/src/io.dart
@@ -493,11 +493,16 @@ final bool runningFromTest = Platform.script.path.endsWith('.test.snapshot');
final bool runningFromSdk =
!runningFromTest && Platform.script.path.endsWith('.snapshot');
+/// A regular expression to match the script path of a pub script running from
+/// source in the Dart repo.
+final _dartRepoRegExp = new RegExp(
+ r"/third_party/pkg_tested/pub/(bin/pub.dart|test/.*_test\.dart)$");
+
/// Whether pub is running from source in the Dart repo.
///
/// This can happen when building Observatory, for example.
final bool runningFromDartRepo =
- Platform.script.path.endsWith('/third_party/pkg_tested/pub/bin/pub.dart');
+ Platform.script.path.contains(_dartRepoRegExp);
/// Resolves [target] relative to the path to pub's `asset` directory.
String assetPath(String target) => runningFromSdk
@@ -546,9 +551,11 @@ final String dartRepoRoot = (() {
throw new StateError("Not running from source in the Dart repo.");
}
- // In the Dart repo, the script is in "third_party/pkg_tested/pub/bin".
- return path.dirname(path.dirname(path.dirname(path.dirname(path.dirname(
- path.fromUri(Platform.script))))));
+ // Get the URL of the repo root in a way that works when either both running
+ // as a test or as a pub executable.
+ var url = Platform.script.replace(
+ path: Platform.script.path.replaceAll(_dartRepoRegExp, ''));
+ return path.fromUri(url);
})();
/// A line-by-line stream of standard input.
« no previous file with comments | « no previous file | test/test_pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698