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

Side by Side Diff: sdk/lib/_internal/pub/test/version_solver_test.dart

Issue 14685002: Backjump on a source or description mismatch. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library pub_update_test; 5 library pub_update_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
11 11
12 import '../lib/src/lock_file.dart'; 12 import '../lib/src/lock_file.dart';
13 import '../lib/src/log.dart' as log;
13 import '../lib/src/package.dart'; 14 import '../lib/src/package.dart';
14 import '../lib/src/pubspec.dart'; 15 import '../lib/src/pubspec.dart';
15 import '../lib/src/sdk.dart' as sdk; 16 import '../lib/src/sdk.dart' as sdk;
16 import '../lib/src/source.dart'; 17 import '../lib/src/source.dart';
17 import '../lib/src/source_registry.dart'; 18 import '../lib/src/source_registry.dart';
18 import '../lib/src/system_cache.dart'; 19 import '../lib/src/system_cache.dart';
19 import '../lib/src/utils.dart'; 20 import '../lib/src/utils.dart';
20 import '../lib/src/version.dart'; 21 import '../lib/src/version.dart';
21 import '../lib/src/solver/version_solver.dart'; 22 import '../lib/src/solver/version_solver.dart';
22 import 'test_pub.dart'; 23 import 'test_pub.dart';
23 24
24 MockSource source1; 25 MockSource source1;
25 MockSource source2; 26 MockSource source2;
26 27
27 main() { 28 main() {
28 initConfig(); 29 initConfig();
29 30
31 // Uncomment this to debug failing tests.
32 // log.showSolver();
33
30 // Since this test isn't run from the SDK, it can't find the "version" file 34 // Since this test isn't run from the SDK, it can't find the "version" file
31 // to load. Instead, just manually inject a version. 35 // to load. Instead, just manually inject a version.
32 sdk.version = new Version(1, 2, 3); 36 sdk.version = new Version(1, 2, 3);
33 37
34 group('basic graph', basicGraph); 38 group('basic graph', basicGraph);
35 group('with lockfile', withLockFile); 39 group('with lockfile', withLockFile);
36 group('root dependency', rootDependency); 40 group('root dependency', rootDependency);
37 group('dev dependency', devDependency); 41 group('dev dependency', devDependency);
38 group('unsolvable', unsolvable); 42 group('unsolvable', unsolvable);
39 group('backtracking', backtracking); 43 group('backtracking', backtracking);
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 'b 2.0.0': {}, 481 'b 2.0.0': {},
478 'b 3.0.0': {}, 482 'b 3.0.0': {},
479 'c 1.0.0': {}, 483 'c 1.0.0': {},
480 }, result: { 484 }, result: {
481 'myapp from root': '0.0.0', 485 'myapp from root': '0.0.0',
482 'a': '1.0.0', 486 'a': '1.0.0',
483 'b': '3.0.0', 487 'b': '3.0.0',
484 'c': '1.0.0' 488 'c': '1.0.0'
485 }, maxTries: 2); 489 }, maxTries: 2);
486 490
491 // Tests that the backjumper will jump past unrelated selections when a
492 // source conflict occurs. This test selects, in order:
493 // - myapp -> a
494 // - myapp -> b
495 // - myapp -> c (1 of 5)
496 // - b -> a
497 // 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.
498 // traverses b's dependency on a after selecting a version of c because
499 // dependencies are traversed breadth-first (all of myapps's immediate deps
500 // before any other their deps).
501 //
502 // This means it doesn't discover the source conflict until after selecting
503 // c. When that happens, it should backjump past c instead of trying older
504 // versions of it since they aren't related to the conflict.
505 testResolve('backjump to conflicting source', {
506 'myapp 0.0.0': {
507 'a': 'any',
508 'b': 'any',
509 'c': 'any'
510 },
511 'a 1.0.0': {},
512 'a 1.0.0 from mock2': {},
513 'b 1.0.0': {
514 'a from mock2': 'any'
515 },
516 'c 1.0.0': {},
517 'c 2.0.0': {},
518 'c 3.0.0': {},
519 'c 4.0.0': {},
520 'c 5.0.0': {},
521 }, error: sourceMismatch('myapp', 'b'), maxTries: 1);
522
523 // Like the above test, but for a conflicting description.
524 testResolve('backjump to conflicting description', {
525 'myapp 0.0.0': {
526 'a-x': 'any',
527 'b': 'any',
528 'c': 'any'
529 },
530 'a-x 1.0.0': {},
531 'a-y 1.0.0': {},
532 'b 1.0.0': {
533 'a-y': 'any'
534 },
535 'c 1.0.0': {},
536 'c 2.0.0': {},
537 'c 3.0.0': {},
538 'c 4.0.0': {},
539 'c 5.0.0': {},
540 }, error: descriptionMismatch('myapp', 'b'), maxTries: 1);
541
487 // Dependencies are ordered so that packages with fewer versions are tried 542 // Dependencies are ordered so that packages with fewer versions are tried
488 // first. Here, there are two valid solutions (either a or b must be 543 // first. Here, there are two valid solutions (either a or b must be
489 // downgraded once). The chosen one depends on which dep is traversed first. 544 // downgraded once). The chosen one depends on which dep is traversed first.
490 // Since b has fewer versions, it will be traversed first, which means a will 545 // Since b has fewer versions, it will be traversed first, which means a will
491 // come later. Since later selections are revised first, a gets downgraded. 546 // come later. Since later selections are revised first, a gets downgraded.
492 testResolve('traverse into package with fewer versions first', { 547 testResolve('traverse into package with fewer versions first', {
493 'myapp 0.0.0': { 548 'myapp 0.0.0': {
494 'a': 'any', 549 'a': 'any',
495 'b': 'any' 550 'b': 'any'
496 }, 551 },
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 }; 1044 };
990 1045
991 var match = new RegExp(r"(.*) from (.*)").firstMatch(description); 1046 var match = new RegExp(r"(.*) from (.*)").firstMatch(description);
992 if (match != null) { 1047 if (match != null) {
993 name = match[1]; 1048 name = match[1];
994 source = sourceNames[match[2]]; 1049 source = sourceNames[match[2]];
995 } 1050 }
996 1051
997 callback(isDev, name, source); 1052 callback(isDev, name, source);
998 } 1053 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698