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

Side by Side Diff: test/version_solver_test.dart

Issue 1528523003: Clean up the semantics of package descriptions. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 5 years 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
« no previous file with comments | « test/upgrade/git/upgrade_to_nonexistent_pubspec_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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;
(...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 /// Keeps track of which package pubspecs have been requested. Ensures that a 1380 /// Keeps track of which package pubspecs have been requested. Ensures that a
1381 /// source is only hit once for a given package and that pub internally 1381 /// source is only hit once for a given package and that pub internally
1382 /// caches the results. 1382 /// caches the results.
1383 final _requestedPubspecs = new Map<String, Set<Version>>(); 1383 final _requestedPubspecs = new Map<String, Set<Version>>();
1384 1384
1385 final String name; 1385 final String name;
1386 final hasMultipleVersions = true; 1386 final hasMultipleVersions = true;
1387 1387
1388 MockSource(this.name); 1388 MockSource(this.name);
1389 1389
1390 dynamic parseDescription(String containingPath, description, 1390 PackageRef parseRef(String name, description, {String containingPath}) =>
1391 {bool fromLockFile: false}) => description; 1391 new PackageRef(name, this.name, description);
1392
1393 PackageId parseId(String name, Version version, description) =>
1394 new PackageId(name, this.name, version, description);
1392 1395
1393 bool descriptionsEqual(description1, description2) => 1396 bool descriptionsEqual(description1, description2) =>
1394 description1 == description2; 1397 description1 == description2;
1395 1398
1396 String getDirectory(PackageId id) => '${id.name}-${id.version}'; 1399 String getDirectory(PackageId id) => '${id.name}-${id.version}';
1397 1400
1398 Future<List<PackageId>> doGetVersions(PackageRef ref) async { 1401 Future<List<PackageId>> doGetVersions(PackageRef ref) async {
1399 // Make sure the solver doesn't request the same thing twice. 1402 // Make sure the solver doesn't request the same thing twice.
1400 if (_requestedVersions.contains(ref.description)) { 1403 if (_requestedVersions.contains(ref.description)) {
1401 throw new Exception('Version list for $description was already ' 1404 throw new Exception('Version list for ${ref.description} was already '
1402 'requested.'); 1405 'requested.');
1403 } 1406 }
1404 1407
1405 _requestedVersions.add(ref.description); 1408 _requestedVersions.add(ref.description);
1406 1409
1407 if (!_packages.containsKey(ref.description)){ 1410 if (!_packages.containsKey(ref.description)){
1408 throw new Exception('MockSource does not have a package matching ' 1411 throw new Exception('MockSource does not have a package matching '
1409 '"${ref.description}".'); 1412 '"${ref.description}".');
1410 } 1413 }
1411 1414
1412 return _packages[ref.description].values 1415 return _packages[ref.description].values.map((package) {
1413 .map((package) => ref.atVersion(package.version)).toList(); 1416 return new PackageId(
1417 ref.name, this.name, package.version, ref.description);
1418 }).toList();
1414 } 1419 }
1415 1420
1416 Future<Pubspec> describeUncached(PackageId id) { 1421 Future<Pubspec> describeUncached(PackageId id) {
1417 return new Future.sync(() { 1422 return new Future.sync(() {
1418 // Make sure the solver doesn't request the same thing twice. 1423 // Make sure the solver doesn't request the same thing twice.
1419 if (_requestedPubspecs.containsKey(id.description) && 1424 if (_requestedPubspecs.containsKey(id.description) &&
1420 _requestedPubspecs[id.description].contains(id.version)) { 1425 _requestedPubspecs[id.description].contains(id.version)) {
1421 throw new Exception('Pubspec for $id was already requested.'); 1426 throw new Exception('Pubspec for $id was already requested.');
1422 } 1427 }
1423 1428
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 } 1534 }
1530 1535
1531 var source = "mock1"; 1536 var source = "mock1";
1532 if (match[7] != null) { 1537 if (match[7] != null) {
1533 source = match[7]; 1538 source = match[7];
1534 if (source == "root") source = null; 1539 if (source == "root") source = null;
1535 } 1540 }
1536 1541
1537 return new PackageId(name, source, parsedVersion, description); 1542 return new PackageId(name, source, parsedVersion, description);
1538 } 1543 }
OLDNEW
« no previous file with comments | « test/upgrade/git/upgrade_to_nonexistent_pubspec_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698