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

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

Issue 11943005: Make integration tests a bit cleaner. (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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 /// failed. 436 /// failed.
437 List<_ScheduledEvent> _scheduledOnException; 437 List<_ScheduledEvent> _scheduledOnException;
438 438
439 /// Set to true when the current batch of scheduled events should be aborted. 439 /// Set to true when the current batch of scheduled events should be aborted.
440 bool _abortScheduled = false; 440 bool _abortScheduled = false;
441 441
442 /// The time (in milliseconds) to wait for the entire scheduled test to 442 /// The time (in milliseconds) to wait for the entire scheduled test to
443 /// complete. 443 /// complete.
444 final _TIMEOUT = 30000; 444 final _TIMEOUT = 30000;
445 445
446 /// Defines an integration test. The [body] should schedule a series of
447 /// operations which will be run asynchronously.
448 integration(String description, body()) {
449 test(description, () {
450 body();
451 _run();
452 });
453 }
454
446 /// Runs all the scheduled events for a test case. This should only be called 455 /// Runs all the scheduled events for a test case. This should only be called
447 /// once per test case. 456 /// once per test case.
448 void run() { 457 void _run() {
449 var createdSandboxDir; 458 var createdSandboxDir;
450 459
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);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 }); 527 });
519 }); 528 });
520 } 529 }
521 530
522 /// A shorthand for [schedulePub] and [run] when no validation needs to be done 531 /// A shorthand for [schedulePub] and [run] when no validation needs to be done
523 /// after Pub has been run. 532 /// after Pub has been run.
524 /// 533 ///
525 /// Any futures in [args] will be resolved before the process is started. 534 /// Any futures in [args] will be resolved before the process is started.
526 void runPub({List args, Pattern output, Pattern error, int exitCode: 0}) { 535 void runPub({List args, Pattern output, Pattern error, int exitCode: 0}) {
527 schedulePub(args: args, output: output, error: error, exitCode: exitCode); 536 schedulePub(args: args, output: output, error: error, exitCode: exitCode);
528 run(); 537 _run();
529 } 538 }
530 539
531 /// Starts a Pub process and returns a [ScheduledProcess] that supports 540 /// Starts a Pub process and returns a [ScheduledProcess] that supports
532 /// interaction with that process. 541 /// interaction with that process.
533 /// 542 ///
534 /// Any futures in [args] will be resolved before the process is started. 543 /// Any futures in [args] will be resolved before the process is started.
535 ScheduledProcess startPub({List args, Future<Uri> tokenEndpoint}) { 544 ScheduledProcess startPub({List args, Future<Uri> tokenEndpoint}) {
536 var process = _scheduleValue((sandboxDir) => 545 var process = _scheduleValue((sandboxDir) =>
537 _doPub(startProcess, sandboxDir, args, tokenEndpoint)); 546 _doPub(startProcess, sandboxDir, args, tokenEndpoint));
538 return new ScheduledProcess("pub", process); 547 return new ScheduledProcess("pub", process);
(...skipping 1000 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
« no previous file with comments | « utils/tests/pub/pub_uploader_test.dart ('k') | utils/tests/pub/update/git/do_not_update_if_unneeded_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698