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

Unified Diff: sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart

Issue 887483002: Don't crash 'pub get' if a dev dependency is broken. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 5 years, 11 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 | « sdk/lib/_internal/pub/lib/src/pubspec.dart ('k') | sdk/lib/_internal/pub/lib/src/source/path.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart
diff --git a/sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart b/sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart
index b339dd24575fc893ba3a4f61f962c0312338b7c9..a9b84e37184be33f42ba2b6ab18c6a423324693d 100644
--- a/sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart
+++ b/sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart
@@ -126,7 +126,7 @@ class BacktrackingSolver {
///
/// Completes with a list of specific package versions if successful or an
/// error if it failed to find a solution.
- Future<SolveResult> solve() async {
+ Future<SolveResult> solve() {
var stopwatch = new Stopwatch();
_logParameters();
@@ -135,35 +135,40 @@ class BacktrackingSolver {
var overrides = _overrides.values.toList();
overrides.sort((a, b) => a.name.compareTo(b.name));
- try {
+ // TODO(nweiz): Use async/await here once
+ // https://github.com/dart-lang/async_await/issues/79 is fixed.
+ return new Future.sync(() {
stopwatch.start();
// Pre-cache the root package's known pubspec.
cache.cache(new PackageId.root(root), root.pubspec);
_validateSdkConstraint(root.pubspec);
- var packages = await _traverseSolution();
+ return _traverseSolution();
+ }).then((packages) {
var pubspecs = new Map.fromIterable(packages,
key: (id) => id.name,
value: (id) => cache.getCachedPubspec(id));
- packages = await Future.wait(
- packages.map((id) => sources[id.source].resolveId(id)));
-
- return new SolveResult.success(sources, root, lockFile, packages,
- overrides, pubspecs, _getAvailableVersions(packages),
- attemptedSolutions);
- } on SolveFailure catch (error) {
+ return Future.wait(
+ packages.map((id) => sources[id.source].resolveId(id)))
+ .then((packages) {
+ return new SolveResult.success(sources, root, lockFile, packages,
+ overrides, pubspecs, _getAvailableVersions(packages),
+ attemptedSolutions);
+ });
+ }).catchError((error) {
+ if (error is! SolveFailure) throw error;
// Wrap a failure in a result so we can attach some other data.
return new SolveResult.failure(sources, root, lockFile, overrides,
error, attemptedSolutions);
- } finally {
+ }).whenComplete(() {
// Gather some solving metrics.
var buffer = new StringBuffer();
buffer.writeln('${runtimeType} took ${stopwatch.elapsed} seconds.');
buffer.writeln(cache.describeResults());
log.solver(buffer);
- }
+ });
}
/// Generates a map containing all of the known available versions for each
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/pubspec.dart ('k') | sdk/lib/_internal/pub/lib/src/source/path.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698