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

Unified Diff: lib/src/util/io.dart

Issue 1055083004: Normalize handling of the package root in the runner. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Unused import Created 5 years, 8 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 | « lib/src/runner/loader.dart ('k') | test/runner/browser/loader_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/util/io.dart
diff --git a/lib/src/util/io.dart b/lib/src/util/io.dart
index 2a1d8ee38135429aed1ca2ce125dc5c90f30b2f4..2f53610bd29418b83e87e91e879d7ec1c159c602 100644
--- a/lib/src/util/io.dart
+++ b/lib/src/util/io.dart
@@ -12,7 +12,7 @@ import 'package:path/path.dart' as p;
import 'package:pub_semver/pub_semver.dart';
import '../backend/operating_system.dart';
-import '../runner/load_exception.dart';
+import '../runner/application_exception.dart';
/// The root directory of the Dart SDK.
final String sdkDir =
@@ -112,17 +112,17 @@ Uri baseUrlForAddress(InternetAddress address, int port) {
return new Uri(scheme: "http", host: address.address, port: port);
}
-/// Returns the package root for a Dart entrypoint at [path].
+/// Returns the package root at [root].
///
-/// If [override] is passed, that's used. If the package root doesn't exist, a
-/// [LoadException] is thrown.
-String packageRootFor(String path, [String override]) {
- var packageRoot = override == null
- ? p.join(p.dirname(path), 'packages')
- : override;
+/// If [override] is passed, that's used. If the package root doesn't exist, an
+/// [ApplicationException] is thrown.
+String packageRootFor(String root, [String override]) {
+ if (root == null) root = p.current;
+ var packageRoot = override == null ? p.join(root, 'packages') : override;
if (!new Directory(packageRoot).existsSync()) {
- throw new LoadException(path, "Directory $packageRoot does not exist.");
+ throw new ApplicationException(
+ "Directory ${p.prettyUri(p.toUri(packageRoot))} does not exist.");
}
return packageRoot;
« no previous file with comments | « lib/src/runner/loader.dart ('k') | test/runner/browser/loader_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698