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

Side by Side Diff: utils/tests/pub/version_solver_test.dart

Issue 12047096: Get rid of RootSource. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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
« utils/pub/package.dart ('K') | « utils/pub/version_solver.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_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 '../../pub/lock_file.dart'; 10 import '../../pub/lock_file.dart';
11 import '../../pub/package.dart'; 11 import '../../pub/package.dart';
12 import '../../pub/pubspec.dart'; 12 import '../../pub/pubspec.dart';
13 import '../../pub/root_source.dart';
14 import '../../pub/source.dart'; 13 import '../../pub/source.dart';
15 import '../../pub/source_registry.dart'; 14 import '../../pub/source_registry.dart';
16 import '../../pub/system_cache.dart'; 15 import '../../pub/system_cache.dart';
17 import '../../pub/utils.dart'; 16 import '../../pub/utils.dart';
18 import '../../pub/version.dart'; 17 import '../../pub/version.dart';
19 import '../../pub/version_solver.dart'; 18 import '../../pub/version_solver.dart';
20 import '../../../pkg/unittest/lib/unittest.dart'; 19 import '../../../pkg/unittest/lib/unittest.dart';
21 20
22 Matcher noVersion(List<String> packages) { 21 Matcher noVersion(List<String> packages) {
23 return predicate((x) { 22 return predicate((x) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 if (!x.toString().contains(package1)) return false; 61 if (!x.toString().contains(package1)) return false;
63 if (!x.toString().contains(package2)) return false; 62 if (!x.toString().contains(package2)) return false;
64 63
65 return true; 64 return true;
66 }, "is a SourceMismatchException"); 65 }, "is a SourceMismatchException");
67 } 66 }
68 67
69 MockSource source1; 68 MockSource source1;
70 MockSource source2; 69 MockSource source2;
71 Source versionlessSource; 70 Source versionlessSource;
72 Source rootSource;
73 71
74 main() { 72 main() {
75 testResolve('no dependencies', { 73 testResolve('no dependencies', {
76 'myapp 0.0.0': {} 74 'myapp 0.0.0': {}
77 }, result: { 75 }, result: {
78 'myapp from root': '0.0.0' 76 'myapp from root': '0.0.0'
79 }); 77 });
80 78
81 testResolve('simple dependency tree', { 79 testResolve('simple dependency tree', {
82 'myapp 0.0.0': { 80 'myapp 0.0.0': {
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 var parts = nameVersion.split(' '); 396 var parts = nameVersion.split(' ');
399 var name = parts[0]; 397 var name = parts[0];
400 var version = parts[1]; 398 var version = parts[1];
401 399
402 var package = source1.mockPackage(name, version, dependencies); 400 var package = source1.mockPackage(name, version, dependencies);
403 if (name == 'myapp') { 401 if (name == 'myapp') {
404 // Don't add the root package to the server, so we can verify that Pub 402 // Don't add the root package to the server, so we can verify that Pub
405 // doesn't try to look up information about the local package on the 403 // doesn't try to look up information about the local package on the
406 // remote server. 404 // remote server.
407 root = package; 405 root = package;
408 rootSource = new RootSource(root);
409 cache.register(rootSource);
410 } else { 406 } else {
411 source.addPackage(package); 407 source.addPackage(package);
412 } 408 }
413 }); 409 });
414 410
415 // Clean up the expectation. 411 // Clean up the expectation.
416 if (result != null) { 412 if (result != null) {
417 var newResult = {}; 413 var newResult = {};
418 result.forEach((name, version) { 414 result.forEach((name, version) {
419 var parsed = parseSource(name); 415 var parsed = parseSource(name);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 534
539 return completer.future; 535 return completer.future;
540 } 536 }
541 537
542 Pair<String, Source> parseSource(String name) { 538 Pair<String, Source> parseSource(String name) {
543 var match = new RegExp(r"(.*) from (.*)").firstMatch(name); 539 var match = new RegExp(r"(.*) from (.*)").firstMatch(name);
544 if (match == null) return new Pair<String, Source>(name, source1); 540 if (match == null) return new Pair<String, Source>(name, source1);
545 switch (match[2]) { 541 switch (match[2]) {
546 case 'mock1': return new Pair<String, Source>(match[1], source1); 542 case 'mock1': return new Pair<String, Source>(match[1], source1);
547 case 'mock2': return new Pair<String, Source>(match[1], source2); 543 case 'mock2': return new Pair<String, Source>(match[1], source2);
548 case 'root': return new Pair<String, Source>(match[1], rootSource); 544 case 'root': return new Pair<String, Source>(match[1], null);
549 case 'versionless': 545 case 'versionless':
550 return new Pair<String, Source>(match[1], versionlessSource); 546 return new Pair<String, Source>(match[1], versionlessSource);
551 } 547 }
552 } 548 }
OLDNEW
« utils/pub/package.dart ('K') | « utils/pub/version_solver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698