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

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

Issue 11867012: Create a unit test config for the pub tests that's prettier. (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
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 /// Test infrastructure for testing pub. Unlike typical unit tests, most pub 5 /// Test infrastructure for testing pub. Unlike typical unit tests, most pub
6 /// tests are integration tests that stage some stuff on the file system, run 6 /// tests are integration tests that stage some stuff on the file system, run
7 /// pub, and then validate the results. This library provides an API to build 7 /// pub, and then validate the results. This library provides an API to build
8 /// tests like that. 8 /// tests like that.
9 library test_pub; 9 library test_pub;
10 10
(...skipping 11 matching lines...) Expand all
22 import '../../pub/entrypoint.dart'; 22 import '../../pub/entrypoint.dart';
23 import '../../pub/git_source.dart'; 23 import '../../pub/git_source.dart';
24 import '../../pub/hosted_source.dart'; 24 import '../../pub/hosted_source.dart';
25 import '../../pub/http.dart'; 25 import '../../pub/http.dart';
26 import '../../pub/io.dart'; 26 import '../../pub/io.dart';
27 import '../../pub/sdk_source.dart'; 27 import '../../pub/sdk_source.dart';
28 import '../../pub/system_cache.dart'; 28 import '../../pub/system_cache.dart';
29 import '../../pub/utils.dart'; 29 import '../../pub/utils.dart';
30 import '../../pub/validator.dart'; 30 import '../../pub/validator.dart';
31 import '../../pub/yaml/yaml.dart'; 31 import '../../pub/yaml/yaml.dart';
32 import 'command_line_config.dart';
33
34 /// This should be called at the top of a test file to set up an appropriate
35 /// test configuration for the machine running the tests.
36 initConfig() {
37 // If we aren't running on the bots, use the human-friendly config.
38 if (new Options().arguments.contains('--human')) {
39 configure(new CommandLineConfiguration());
40 }
41 }
32 42
33 /// Creates a new [FileDescriptor] with [name] and [contents]. 43 /// Creates a new [FileDescriptor] with [name] and [contents].
34 FileDescriptor file(Pattern name, String contents) => 44 FileDescriptor file(Pattern name, String contents) =>
35 new FileDescriptor(name, contents); 45 new FileDescriptor(name, contents);
36 46
37 /// Creates a new [DirectoryDescriptor] with [name] and [contents]. 47 /// Creates a new [DirectoryDescriptor] with [name] and [contents].
38 DirectoryDescriptor dir(Pattern name, [List<Descriptor> contents]) => 48 DirectoryDescriptor dir(Pattern name, [List<Descriptor> contents]) =>
39 new DirectoryDescriptor(name, contents); 49 new DirectoryDescriptor(name, contents);
40 50
41 /// Creates a new [FutureDescriptor] wrapping [future]. 51 /// Creates a new [FutureDescriptor] wrapping [future].
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 bool _abortScheduled = false; 450 bool _abortScheduled = false;
441 451
442 /// The time (in milliseconds) to wait for the entire scheduled test to 452 /// The time (in milliseconds) to wait for the entire scheduled test to
443 /// complete. 453 /// complete.
444 final _TIMEOUT = 30000; 454 final _TIMEOUT = 30000;
445 455
446 /// Runs all the scheduled events for a test case. This should only be called 456 /// Runs all the scheduled events for a test case. This should only be called
447 /// once per test case. 457 /// once per test case.
448 void run() { 458 void run() {
449 var createdSandboxDir; 459 var createdSandboxDir;
450
451 var asyncDone = expectAsync0(() {}); 460 var asyncDone = expectAsync0(() {});
452 461
453 Future cleanup() { 462 Future cleanup() {
454 return _runScheduled(createdSandboxDir, _scheduledCleanup).then((_) { 463 return _runScheduled(createdSandboxDir, _scheduledCleanup).then((_) {
455 _scheduled = null; 464 _scheduled = null;
456 _scheduledCleanup = null; 465 _scheduledCleanup = null;
457 _scheduledOnException = null; 466 _scheduledOnException = null;
458 if (createdSandboxDir != null) return deleteDir(createdSandboxDir); 467 if (createdSandboxDir != null) return deleteDir(createdSandboxDir);
459 return new Future.immediate(null); 468 return new Future.immediate(null);
460 }); 469 });
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 /// calling [completion] is unnecessary. 1548 /// calling [completion] is unnecessary.
1540 void expectLater(Future actual, matcher, {String reason, 1549 void expectLater(Future actual, matcher, {String reason,
1541 FailureHandler failureHandler, bool verbose: false}) { 1550 FailureHandler failureHandler, bool verbose: false}) {
1542 _schedule((_) { 1551 _schedule((_) {
1543 return actual.then((value) { 1552 return actual.then((value) {
1544 expect(value, matcher, reason: reason, failureHandler: failureHandler, 1553 expect(value, matcher, reason: reason, failureHandler: failureHandler,
1545 verbose: false); 1554 verbose: false);
1546 }); 1555 });
1547 }); 1556 });
1548 } 1557 }
OLDNEW
« utils/tests/pub/command_line_config.dart ('K') | « utils/tests/pub/command_line_config.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698