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:pub/src/lock_file.dart'; | 9 import 'package:pub/src/lock_file.dart'; |
10 import 'package:pub/src/log.dart' as log; | 10 import 'package:pub/src/log.dart' as log; |
11 import 'package:pub/src/package.dart'; | 11 import 'package:pub/src/package.dart'; |
12 import 'package:pub/src/pubspec.dart'; | 12 import 'package:pub/src/pubspec.dart'; |
13 import 'package:pub/src/sdk.dart' as sdk; | 13 import 'package:pub/src/sdk.dart' as sdk; |
14 import 'package:pub/src/solver/version_solver.dart'; | 14 import 'package:pub/src/solver/version_solver.dart'; |
15 import 'package:pub/src/source/cached.dart'; | 15 import 'package:pub/src/source/cached.dart'; |
16 import 'package:pub/src/system_cache.dart'; | 16 import 'package:pub/src/system_cache.dart'; |
17 import 'package:pub/src/utils.dart'; | 17 import 'package:pub/src/utils.dart'; |
18 import 'package:pub_semver/pub_semver.dart'; | 18 import 'package:pub_semver/pub_semver.dart'; |
19 import 'package:test/test.dart'; | 19 import 'package:test/test.dart'; |
20 | 20 |
21 import 'test_pub.dart'; | |
22 | |
23 MockSource source1; | 21 MockSource source1; |
24 MockSource source2; | 22 MockSource source2; |
25 | 23 |
26 main() { | 24 main() { |
27 // Uncomment this to debug failing tests. | 25 // Uncomment this to debug failing tests. |
28 // log.verbosity = log.Verbosity.SOLVER; | 26 // log.verbosity = log.Verbosity.SOLVER; |
29 | 27 |
30 // Since this test isn't run from the SDK, it can't find the "version" file | 28 // 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. | 29 // to load. Instead, just manually inject a version. |
32 sdk.version = new Version(1, 2, 3); | 30 sdk.version = new Version(1, 2, 3); |
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 'a 2.0.0-dev.3': {} | 1101 'a 2.0.0-dev.3': {} |
1104 }, result: { | 1102 }, result: { |
1105 'myapp from root': '0.0.0', | 1103 'myapp from root': '0.0.0', |
1106 'a': '2.0.0-dev.1' | 1104 'a': '2.0.0-dev.1' |
1107 }, downgrade: true); | 1105 }, downgrade: true); |
1108 } | 1106 } |
1109 | 1107 |
1110 testResolve(String description, Map packages, { | 1108 testResolve(String description, Map packages, { |
1111 Map lockfile, Map overrides, Map result, FailMatcherBuilder error, | 1109 Map lockfile, Map overrides, Map result, FailMatcherBuilder error, |
1112 int maxTries, bool downgrade: false}) { | 1110 int maxTries, bool downgrade: false}) { |
1113 _testResolve(test, description, packages, lockfile: lockfile, | |
1114 overrides: overrides, result: result, error: error, maxTries: maxTries, | |
1115 downgrade: downgrade); | |
1116 } | |
1117 | |
1118 solo_testResolve(String description, Map packages, { | |
1119 Map lockfile, Map overrides, Map result, FailMatcherBuilder error, | |
1120 int maxTries, bool downgrade: false}) { | |
1121 log.verbosity = log.Verbosity.SOLVER; | |
1122 _testResolve(solo_test, description, packages, lockfile: lockfile, | |
1123 overrides: overrides, result: result, error: error, maxTries: maxTries, | |
1124 downgrade: downgrade); | |
1125 } | |
1126 | |
1127 _testResolve(void testFn(String description, Function body), | |
1128 String description, Map packages, { | |
1129 Map lockfile, Map overrides, Map result, FailMatcherBuilder error, | |
1130 int maxTries, bool downgrade: false}) { | |
1131 if (maxTries == null) maxTries = 1; | 1111 if (maxTries == null) maxTries = 1; |
1132 | 1112 |
1133 testFn(description, () { | 1113 test(description, () { |
1134 var cache = new SystemCache('.'); | 1114 var cache = new SystemCache('.'); |
1135 source1 = new MockSource('mock1'); | 1115 source1 = new MockSource('mock1'); |
1136 source2 = new MockSource('mock2'); | 1116 source2 = new MockSource('mock2'); |
1137 cache.register(source1); | 1117 cache.register(source1); |
1138 cache.register(source2); | 1118 cache.register(source2); |
1139 cache.sources.setDefault(source1.name); | 1119 cache.sources.setDefault(source1.name); |
1140 | 1120 |
1141 // Build the test package graph. | 1121 // Build the test package graph. |
1142 var root; | 1122 var root; |
1143 packages.forEach((description, dependencies) { | 1123 packages.forEach((description, dependencies) { |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1432 return _packages[id.description][id.version].pubspec; | 1412 return _packages[id.description][id.version].pubspec; |
1433 }); | 1413 }); |
1434 } | 1414 } |
1435 | 1415 |
1436 Future<Package> downloadToSystemCache(PackageId id) => | 1416 Future<Package> downloadToSystemCache(PackageId id) => |
1437 throw new UnsupportedError('Cannot download mock packages'); | 1417 throw new UnsupportedError('Cannot download mock packages'); |
1438 | 1418 |
1439 List<Package> getCachedPackages() => | 1419 List<Package> getCachedPackages() => |
1440 throw new UnsupportedError('Cannot get mock packages'); | 1420 throw new UnsupportedError('Cannot get mock packages'); |
1441 | 1421 |
1442 Future<Pair<List<Package>, List<Package>>> repairCachedPackages() => | 1422 Future<Pair<List<PackageId>, List<PackageId>>> repairCachedPackages() => |
1443 throw new UnsupportedError('Cannot repair mock packages'); | 1423 throw new UnsupportedError('Cannot repair mock packages'); |
1444 | 1424 |
1445 void addPackage(String description, Package package) { | 1425 void addPackage(String description, Package package) { |
1446 _packages.putIfAbsent(description, () => new Map<Version, Package>()); | 1426 _packages.putIfAbsent(description, () => new Map<Version, Package>()); |
1447 _packages[description][package.version] = package; | 1427 _packages[description][package.version] = package; |
1448 } | 1428 } |
1449 } | 1429 } |
1450 | 1430 |
1451 Package mockPackage(PackageId id, Map dependencyStrings, Map overrides) { | 1431 Package mockPackage(PackageId id, Map dependencyStrings, Map overrides) { |
1452 var sdkConstraint = null; | 1432 var sdkConstraint = null; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1534 } | 1514 } |
1535 | 1515 |
1536 var source = "mock1"; | 1516 var source = "mock1"; |
1537 if (match[7] != null) { | 1517 if (match[7] != null) { |
1538 source = match[7]; | 1518 source = match[7]; |
1539 if (source == "root") source = null; | 1519 if (source == "root") source = null; |
1540 } | 1520 } |
1541 | 1521 |
1542 return new PackageId(name, source, parsedVersion, description); | 1522 return new PackageId(name, source, parsedVersion, description); |
1543 } | 1523 } |
OLD | NEW |