| OLD | NEW |
| 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_upgrade_test; | 5 library pub_upgrade_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 | 10 |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 | 406 |
| 407 // This is a regression test for #15550. | 407 // This is a regression test for #15550. |
| 408 testResolve('no version that matches while backtracking', { | 408 testResolve('no version that matches while backtracking', { |
| 409 'myapp 0.0.0': { | 409 'myapp 0.0.0': { |
| 410 'a': 'any', | 410 'a': 'any', |
| 411 'b': '>1.0.0' | 411 'b': '>1.0.0' |
| 412 }, | 412 }, |
| 413 'a 1.0.0': {}, | 413 'a 1.0.0': {}, |
| 414 'b 1.0.0': {} | 414 'b 1.0.0': {} |
| 415 }, error: noVersion(['myapp', 'b']), maxTries: 1); | 415 }, error: noVersion(['myapp', 'b']), maxTries: 1); |
| 416 |
| 417 |
| 418 // This is a regression test for #18300. |
| 419 testResolve('...', { |
| 420 "myapp 0.0.0": { |
| 421 "angular": "any", |
| 422 "collection": "any" |
| 423 }, |
| 424 "analyzer 0.12.2": {}, |
| 425 "angular 0.10.0": { |
| 426 "di": ">=0.0.32 <0.1.0", |
| 427 "collection": ">=0.9.1 <1.0.0" |
| 428 }, |
| 429 "angular 0.9.11": { |
| 430 "di": ">=0.0.32 <0.1.0", |
| 431 "collection": ">=0.9.1 <1.0.0" |
| 432 }, |
| 433 "angular 0.9.10": { |
| 434 "di": ">=0.0.32 <0.1.0", |
| 435 "collection": ">=0.9.1 <1.0.0" |
| 436 }, |
| 437 "collection 0.9.0": {}, |
| 438 "collection 0.9.1": {}, |
| 439 "di 0.0.37": {"analyzer": ">=0.13.0 <0.14.0"}, |
| 440 "di 0.0.36": {"analyzer": ">=0.13.0 <0.14.0"} |
| 441 }, error: noVersion(['myapp', 'angular', 'collection']), maxTries: 9); |
| 416 } | 442 } |
| 417 | 443 |
| 418 badSource() { | 444 badSource() { |
| 419 testResolve('fail if the root package has a bad source in dep', { | 445 testResolve('fail if the root package has a bad source in dep', { |
| 420 'myapp 0.0.0': { | 446 'myapp 0.0.0': { |
| 421 'foo from bad': 'any' | 447 'foo from bad': 'any' |
| 422 }, | 448 }, |
| 423 }, error: unknownSource('myapp', 'foo', 'bad')); | 449 }, error: unknownSource('myapp', 'foo', 'bad')); |
| 424 | 450 |
| 425 testResolve('fail if the root package has a bad source in dev dep', { | 451 testResolve('fail if the root package has a bad source in dev dep', { |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 'b 4.0.0': {'c': '2.0.0'}, | 700 'b 4.0.0': {'c': '2.0.0'}, |
| 675 'c 1.0.0': {}, | 701 'c 1.0.0': {}, |
| 676 'c 2.0.0': {}, | 702 'c 2.0.0': {}, |
| 677 }, result: { | 703 }, result: { |
| 678 'myapp from root': '0.0.0', | 704 'myapp from root': '0.0.0', |
| 679 'a': '4.0.0', | 705 'a': '4.0.0', |
| 680 'b': '4.0.0', | 706 'b': '4.0.0', |
| 681 'c': '2.0.0' | 707 'c': '2.0.0' |
| 682 }, maxTries: 2); | 708 }, maxTries: 2); |
| 683 | 709 |
| 710 // This is similar to the above test. When getting the number of versions of |
| 711 // a package to determine which to traverse first, versions that are |
| 712 // disallowed by the root package's constraints should not be considered. |
| 713 // Here, foo has more versions of bar in total (4), but fewer that meet |
| 714 // myapp's constraints (only 2). There is no solution, but we will do less |
| 715 // backtracking if foo is tested first. |
| 716 testResolve('take root package constraints into counting versions', { |
| 717 "myapp 0.0.0": { |
| 718 "foo": ">2.0.0", |
| 719 "bar": "any" |
| 720 }, |
| 721 "foo 1.0.0": {"none": "2.0.0"}, |
| 722 "foo 2.0.0": {"none": "2.0.0"}, |
| 723 "foo 3.0.0": {"none": "2.0.0"}, |
| 724 "foo 4.0.0": {"none": "2.0.0"}, |
| 725 "bar 1.0.0": {}, |
| 726 "bar 2.0.0": {}, |
| 727 "bar 3.0.0": {}, |
| 728 "none 1.0.0": {} |
| 729 }, error: noVersion(["foo", "none"]), maxTries: 2); |
| 730 |
| 684 // This sets up a hundred versions of foo and bar, 0.0.0 through 9.9.0. Each | 731 // This sets up a hundred versions of foo and bar, 0.0.0 through 9.9.0. Each |
| 685 // version of foo depends on a baz with the same major version. Each version | 732 // version of foo depends on a baz with the same major version. Each version |
| 686 // of bar depends on a baz with the same minor version. There is only one | 733 // of bar depends on a baz with the same minor version. There is only one |
| 687 // version of baz, 0.0.0, so only older versions of foo and bar will | 734 // version of baz, 0.0.0, so only older versions of foo and bar will |
| 688 // satisfy it. | 735 // satisfy it. |
| 689 var map = { | 736 var map = { |
| 690 'myapp 0.0.0': { | 737 'myapp 0.0.0': { |
| 691 'foo': 'any', | 738 'foo': 'any', |
| 692 'bar': 'any' | 739 'bar': 'any' |
| 693 }, | 740 }, |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1365 /// of the package description, but not its name, so the description here is | 1412 /// of the package description, but not its name, so the description here is |
| 1366 /// "foo-xyz". | 1413 /// "foo-xyz". |
| 1367 /// | 1414 /// |
| 1368 /// This is followed by an optional [Version]. If [version] is provided, then | 1415 /// This is followed by an optional [Version]. If [version] is provided, then |
| 1369 /// it is parsed to a [Version], and [text] should *not* also contain a | 1416 /// it is parsed to a [Version], and [text] should *not* also contain a |
| 1370 /// version string. | 1417 /// version string. |
| 1371 /// | 1418 /// |
| 1372 /// The "from mock" optional suffix is the name of a source for the package. | 1419 /// The "from mock" optional suffix is the name of a source for the package. |
| 1373 /// If omitted, it defaults to "mock1". | 1420 /// If omitted, it defaults to "mock1". |
| 1374 PackageId parseSpec(String text, [String version]) { | 1421 PackageId parseSpec(String text, [String version]) { |
| 1375 var pattern = new RegExp(r"(([a-z]*)(-[a-z]+)?)( ([^ ]+))?( from (.*))?$"); | 1422 var pattern = new RegExp(r"(([a-z_]*)(-[a-z_]+)?)( ([^ ]+))?( from (.*))?$"); |
| 1376 var match = pattern.firstMatch(text); | 1423 var match = pattern.firstMatch(text); |
| 1377 if (match == null) { | 1424 if (match == null) { |
| 1378 throw new FormatException("Could not parse spec '$text'."); | 1425 throw new FormatException("Could not parse spec '$text'."); |
| 1379 } | 1426 } |
| 1380 | 1427 |
| 1381 var description = match[1]; | 1428 var description = match[1]; |
| 1382 var name = match[2]; | 1429 var name = match[2]; |
| 1383 | 1430 |
| 1384 var parsedVersion; | 1431 var parsedVersion; |
| 1385 if (version != null) { | 1432 if (version != null) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1398 } | 1445 } |
| 1399 | 1446 |
| 1400 var source = "mock1"; | 1447 var source = "mock1"; |
| 1401 if (match[7] != null) { | 1448 if (match[7] != null) { |
| 1402 source = match[7]; | 1449 source = match[7]; |
| 1403 if (source == "root") source = null; | 1450 if (source == "root") source = null; |
| 1404 } | 1451 } |
| 1405 | 1452 |
| 1406 return new PackageId(name, source, parsedVersion, description); | 1453 return new PackageId(name, source, parsedVersion, description); |
| 1407 } | 1454 } |
| OLD | NEW |