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 |
11 import '../lib/src/lock_file.dart'; | 11 import '../lib/src/lock_file.dart'; |
12 import '../lib/src/log.dart' as log; | 12 import '../lib/src/log.dart' as log; |
13 import '../lib/src/package.dart'; | 13 import '../lib/src/package.dart'; |
14 import '../lib/src/pubspec.dart'; | 14 import '../lib/src/pubspec.dart'; |
15 import '../lib/src/sdk.dart' as sdk; | 15 import '../lib/src/sdk.dart' as sdk; |
16 import '../lib/src/source.dart'; | 16 import '../lib/src/source.dart'; |
17 import '../lib/src/system_cache.dart'; | 17 import '../lib/src/system_cache.dart'; |
| 18 import '../lib/src/utils.dart'; |
18 import '../lib/src/version.dart'; | 19 import '../lib/src/version.dart'; |
19 import '../lib/src/solver/version_solver.dart'; | 20 import '../lib/src/solver/version_solver.dart'; |
20 import 'test_pub.dart'; | 21 import 'test_pub.dart'; |
21 | 22 |
22 MockSource source1; | 23 MockSource source1; |
23 MockSource source2; | 24 MockSource source2; |
24 | 25 |
25 main() { | 26 main() { |
26 initConfig(); | 27 initConfig(); |
27 | 28 |
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1263 final String name; | 1264 final String name; |
1264 bool get shouldCache => true; | 1265 bool get shouldCache => true; |
1265 | 1266 |
1266 MockSource(this.name); | 1267 MockSource(this.name); |
1267 | 1268 |
1268 Future<String> systemCacheDirectory(PackageId id) { | 1269 Future<String> systemCacheDirectory(PackageId id) { |
1269 return new Future.value('${id.name}-${id.version}'); | 1270 return new Future.value('${id.name}-${id.version}'); |
1270 } | 1271 } |
1271 | 1272 |
1272 Future<List<Version>> getVersions(String name, String description) { | 1273 Future<List<Version>> getVersions(String name, String description) { |
1273 return new Future.sync(() { | 1274 return syncFuture(() { |
1274 // Make sure the solver doesn't request the same thing twice. | 1275 // Make sure the solver doesn't request the same thing twice. |
1275 if (_requestedVersions.contains(description)) { | 1276 if (_requestedVersions.contains(description)) { |
1276 throw new Exception('Version list for $description was already ' | 1277 throw new Exception('Version list for $description was already ' |
1277 'requested.'); | 1278 'requested.'); |
1278 } | 1279 } |
1279 | 1280 |
1280 _requestedVersions.add(description); | 1281 _requestedVersions.add(description); |
1281 | 1282 |
1282 if (!_packages.containsKey(description)){ | 1283 if (!_packages.containsKey(description)){ |
1283 throw new Exception('MockSource does not have a package matching ' | 1284 throw new Exception('MockSource does not have a package matching ' |
1284 '"$description".'); | 1285 '"$description".'); |
1285 } | 1286 } |
1286 | 1287 |
1287 return _packages[description].keys.toList(); | 1288 return _packages[description].keys.toList(); |
1288 }); | 1289 }); |
1289 } | 1290 } |
1290 | 1291 |
1291 Future<Pubspec> describe(PackageId id) { | 1292 Future<Pubspec> describe(PackageId id) { |
1292 return new Future.sync(() { | 1293 return syncFuture(() { |
1293 // Make sure the solver doesn't request the same thing twice. | 1294 // Make sure the solver doesn't request the same thing twice. |
1294 if (_requestedPubspecs.containsKey(id.description) && | 1295 if (_requestedPubspecs.containsKey(id.description) && |
1295 _requestedPubspecs[id.description].contains(id.version)) { | 1296 _requestedPubspecs[id.description].contains(id.version)) { |
1296 throw new Exception('Pubspec for $id was already requested.'); | 1297 throw new Exception('Pubspec for $id was already requested.'); |
1297 } | 1298 } |
1298 | 1299 |
1299 _requestedPubspecs.putIfAbsent(id.description, () => new Set<Version>()); | 1300 _requestedPubspecs.putIfAbsent(id.description, () => new Set<Version>()); |
1300 _requestedPubspecs[id.description].add(id.version); | 1301 _requestedPubspecs[id.description].add(id.version); |
1301 | 1302 |
1302 return _packages[id.description][id.version].pubspec; | 1303 return _packages[id.description][id.version].pubspec; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 } | 1398 } |
1398 | 1399 |
1399 var source = "mock1"; | 1400 var source = "mock1"; |
1400 if (match[7] != null) { | 1401 if (match[7] != null) { |
1401 source = match[7]; | 1402 source = match[7]; |
1402 if (source == "root") source = null; | 1403 if (source == "root") source = null; |
1403 } | 1404 } |
1404 | 1405 |
1405 return new PackageId(name, source, parsedVersion, description); | 1406 return new PackageId(name, source, parsedVersion, description); |
1406 } | 1407 } |
OLD | NEW |