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

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

Issue 10916034: Rename "repo" source to "hosted". (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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
« no previous file with comments | « utils/tests/pub/pub_update_repo_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 /** 5 /**
6 * Test infrastructure for testing pub. Unlike typical unit tests, most pub 6 * Test infrastructure for testing pub. Unlike typical unit tests, most pub
7 * tests are integration tests that stage some stuff on the file system, run 7 * tests are integration tests that stage some stuff on the file system, run
8 * pub, and then validate the results. This library provides an API to build 8 * pub, and then validate the results. This library provides an API to build
9 * tests like that. 9 * tests like that.
10 */ 10 */
11 #library('test_pub'); 11 #library('test_pub');
12 12
13 #import('dart:io'); 13 #import('dart:io');
14 #import('dart:isolate'); 14 #import('dart:isolate');
15 #import('dart:json'); 15 #import('dart:json');
16 #import('dart:math'); 16 #import('dart:math');
17 #import('dart:uri'); 17 #import('dart:uri');
18 18
19 #import('../../../pkg/unittest/unittest.dart'); 19 #import('../../../pkg/unittest/unittest.dart');
20 #import('../../lib/file_system.dart', prefix: 'fs'); 20 #import('../../lib/file_system.dart', prefix: 'fs');
21 #import('../../pub/git_source.dart'); 21 #import('../../pub/git_source.dart');
22 #import('../../pub/hosted_source.dart');
22 #import('../../pub/io.dart'); 23 #import('../../pub/io.dart');
23 #import('../../pub/repo_source.dart');
24 #import('../../pub/sdk_source.dart'); 24 #import('../../pub/sdk_source.dart');
25 #import('../../pub/utils.dart'); 25 #import('../../pub/utils.dart');
26 #import('../../pub/yaml/yaml.dart'); 26 #import('../../pub/yaml/yaml.dart');
27 27
28 /** 28 /**
29 * Creates a new [FileDescriptor] with [name] and [contents]. 29 * Creates a new [FileDescriptor] with [name] and [contents].
30 */ 30 */
31 FileDescriptor file(Pattern name, String contents) => 31 FileDescriptor file(Pattern name, String contents) =>
32 new FileDescriptor(name, contents); 32 new FileDescriptor(name, contents);
33 33
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 } 258 }
259 return package; 259 return package;
260 } 260 }
261 261
262 /** 262 /**
263 * Describes a map representing a dependency on a package in the package 263 * Describes a map representing a dependency on a package in the package
264 * repository. 264 * repository.
265 */ 265 */
266 Map dependency(String name, [String versionConstraint]) { 266 Map dependency(String name, [String versionConstraint]) {
267 var url = port.transform((p) => "http://localhost:$p"); 267 var url = port.transform((p) => "http://localhost:$p");
268 var dependency = {"repo": {"name": name, "url": url}}; 268 var dependency = {"hosted": {"name": name, "url": url}};
269 if (versionConstraint != null) dependency["version"] = versionConstraint; 269 if (versionConstraint != null) dependency["version"] = versionConstraint;
270 return dependency; 270 return dependency;
271 } 271 }
272 272
273 /** 273 /**
274 * Describes a directory for a package installed from the mock package repo. 274 * Describes a directory for a package installed from the mock package repo.
275 * This directory is of the form found in the `packages/` directory. 275 * This directory is of the form found in the `packages/` directory.
276 */ 276 */
277 DirectoryDescriptor packageDir(String name, String version) { 277 DirectoryDescriptor packageDir(String name, String version) {
278 return dir(name, [ 278 return dir(name, [
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 */ 331 */
332 DirectoryDescriptor cacheDir(Map packages) { 332 DirectoryDescriptor cacheDir(Map packages) {
333 var contents = <Descriptor>[]; 333 var contents = <Descriptor>[];
334 packages.forEach((name, versions) { 334 packages.forEach((name, versions) {
335 if (versions is! List) versions = [versions]; 335 if (versions is! List) versions = [versions];
336 for (var version in versions) { 336 for (var version in versions) {
337 contents.add(packageCacheDir(name, version)); 337 contents.add(packageCacheDir(name, version));
338 } 338 }
339 }); 339 });
340 return dir(cachePath, [ 340 return dir(cachePath, [
341 dir('repo', [ 341 dir('hosted', [
342 async(port.transform((p) => dir('localhost%58$p', contents))) 342 async(port.transform((p) => dir('localhost%58$p', contents)))
343 ]) 343 ])
344 ]); 344 ]);
345 } 345 }
346 346
347 /** 347 /**
348 * Describes the application directory, containing only a pubspec specifying the 348 * Describes the application directory, containing only a pubspec specifying the
349 * given [dependencies]. 349 * given [dependencies].
350 */ 350 */
351 DirectoryDescriptor appDir(List dependencies) => 351 DirectoryDescriptor appDir(List dependencies) =>
352 dir(appPath, [appPubspec(dependencies)]); 352 dir(appPath, [appPubspec(dependencies)]);
353 353
354 /** 354 /**
355 * Converts a list of dependencies as passed to [package] into a hash as used in 355 * Converts a list of dependencies as passed to [package] into a hash as used in
356 * a pubspec. 356 * a pubspec.
357 */ 357 */
358 Future<Map> _dependencyListToMap(List<Map> dependencies) { 358 Future<Map> _dependencyListToMap(List<Map> dependencies) {
359 return _awaitObject(dependencies).transform((resolvedDependencies) { 359 return _awaitObject(dependencies).transform((resolvedDependencies) {
360 var result = <String, Map>{}; 360 var result = <String, Map>{};
361 for (var dependency in resolvedDependencies) { 361 for (var dependency in resolvedDependencies) {
362 var keys = dependency.getKeys().filter((key) => key != "version"); 362 var keys = dependency.getKeys().filter((key) => key != "version");
363 var sourceName = only(keys); 363 var sourceName = only(keys);
364 var source; 364 var source;
365 switch (sourceName) { 365 switch (sourceName) {
366 case "git": 366 case "git":
367 source = new GitSource(); 367 source = new GitSource();
368 break; 368 break;
369 case "repo": 369 case "hosted":
370 source = new RepoSource(); 370 source = new HostedSource();
371 break; 371 break;
372 case "sdk": 372 case "sdk":
373 source = new SdkSource(''); 373 source = new SdkSource('');
374 break; 374 break;
375 default: 375 default:
376 throw 'Unknown source "$sourceName"'; 376 throw 'Unknown source "$sourceName"';
377 } 377 }
378 378
379 result[source.packageName(dependency[sourceName])] = dependency; 379 result[source.packageName(dependency[sourceName])] = dependency;
380 } 380 }
381 return result; 381 return result;
382 }); 382 });
383 } 383 }
384 384
385 /** 385 /**
386 * The path of the package cache directory used for tests. Relative to the 386 * The path of the package cache directory used for tests. Relative to the
387 * sandbox directory. 387 * sandbox directory.
388 */ 388 */
389 final String cachePath = "cache"; 389 final String cachePath = "cache";
390 390
391 /** 391 /**
392 * The path of the mock SDK directory used for tests. Relative to the sandbox 392 * The path of the mock SDK directory used for tests. Relative to the sandbox
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 } 1091 }
1092 1092
1093 /** 1093 /**
1094 * Schedules a callback to be called after Pub is run with [runPub], even if it 1094 * Schedules a callback to be called after Pub is run with [runPub], even if it
1095 * fails. 1095 * fails.
1096 */ 1096 */
1097 void _scheduleCleanup(_ScheduledEvent event) { 1097 void _scheduleCleanup(_ScheduledEvent event) {
1098 if (_scheduledCleanup == null) _scheduledCleanup = []; 1098 if (_scheduledCleanup == null) _scheduledCleanup = [];
1099 _scheduledCleanup.add(event); 1099 _scheduledCleanup.add(event);
1100 } 1100 }
OLDNEW
« no previous file with comments | « utils/tests/pub/pub_update_repo_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698