Chromium Code Reviews| Index: sdk/lib/_internal/pub/test/version_solver_test.dart |
| diff --git a/sdk/lib/_internal/pub/test/version_solver_test.dart b/sdk/lib/_internal/pub/test/version_solver_test.dart |
| index 6c2cb22784290651e90b911bf57aef1b9cb9575b..f546e4980a0e0d53d2930ce7d0e50cac6764939c 100644 |
| --- a/sdk/lib/_internal/pub/test/version_solver_test.dart |
| +++ b/sdk/lib/_internal/pub/test/version_solver_test.dart |
| @@ -10,6 +10,7 @@ import 'dart:io'; |
| import 'package:unittest/unittest.dart'; |
| import '../lib/src/lock_file.dart'; |
| +import '../lib/src/log.dart' as log; |
| import '../lib/src/package.dart'; |
| import '../lib/src/pubspec.dart'; |
| import '../lib/src/sdk.dart' as sdk; |
| @@ -27,6 +28,9 @@ MockSource source2; |
| main() { |
| initConfig(); |
| + // Uncomment this to debug failing tests. |
| + // log.showSolver(); |
| + |
| // Since this test isn't run from the SDK, it can't find the "version" file |
| // to load. Instead, just manually inject a version. |
| sdk.version = new Version(1, 2, 3); |
| @@ -484,6 +488,57 @@ backtracking() { |
| 'c': '1.0.0' |
| }, maxTries: 2); |
| + // Tests that the backjumper will jump past unrelated selections when a |
| + // source conflict occurs. This test selects, in order: |
| + // - myapp -> a |
| + // - myapp -> b |
| + // - myapp -> c (1 of 5) |
| + // - b -> a |
| + // It selects a and b first because they have fewer versions then c. It |
|
nweiz
2013/04/30 22:00:29
"then" -> "than"
Bob Nystrom
2013/05/01 01:06:15
Done.
|
| + // traverses b's dependency on a after selecting a version of c because |
| + // dependencies are traversed breadth-first (all of myapps's immediate deps |
| + // before any other their deps). |
| + // |
| + // This means it doesn't discover the source conflict until after selecting |
| + // c. When that happens, it should backjump past c instead of trying older |
| + // versions of it since they aren't related to the conflict. |
| + testResolve('backjump to conflicting source', { |
| + 'myapp 0.0.0': { |
| + 'a': 'any', |
| + 'b': 'any', |
| + 'c': 'any' |
| + }, |
| + 'a 1.0.0': {}, |
| + 'a 1.0.0 from mock2': {}, |
| + 'b 1.0.0': { |
| + 'a from mock2': 'any' |
| + }, |
| + 'c 1.0.0': {}, |
| + 'c 2.0.0': {}, |
| + 'c 3.0.0': {}, |
| + 'c 4.0.0': {}, |
| + 'c 5.0.0': {}, |
| + }, error: sourceMismatch('myapp', 'b'), maxTries: 1); |
| + |
| + // Like the above test, but for a conflicting description. |
| + testResolve('backjump to conflicting description', { |
| + 'myapp 0.0.0': { |
| + 'a-x': 'any', |
| + 'b': 'any', |
| + 'c': 'any' |
| + }, |
| + 'a-x 1.0.0': {}, |
| + 'a-y 1.0.0': {}, |
| + 'b 1.0.0': { |
| + 'a-y': 'any' |
| + }, |
| + 'c 1.0.0': {}, |
| + 'c 2.0.0': {}, |
| + 'c 3.0.0': {}, |
| + 'c 4.0.0': {}, |
| + 'c 5.0.0': {}, |
| + }, error: descriptionMismatch('myapp', 'b'), maxTries: 1); |
| + |
| // Dependencies are ordered so that packages with fewer versions are tried |
| // first. Here, there are two valid solutions (either a or b must be |
| // downgraded once). The chosen one depends on which dep is traversed first. |