| OLD | NEW |
| 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 */ |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 | 502 |
| 503 /// The list of events that are scheduled to run after the test case only if it | 503 /// The list of events that are scheduled to run after the test case only if it |
| 504 /// failed. | 504 /// failed. |
| 505 List<_ScheduledEvent> _scheduledOnException; | 505 List<_ScheduledEvent> _scheduledOnException; |
| 506 | 506 |
| 507 /** | 507 /** |
| 508 * Set to true when the current batch of scheduled events should be aborted. | 508 * Set to true when the current batch of scheduled events should be aborted. |
| 509 */ | 509 */ |
| 510 bool _abortScheduled = false; | 510 bool _abortScheduled = false; |
| 511 | 511 |
| 512 /// The time (in milliseconds) to wait for the entire scheduled test to |
| 513 /// complete. |
| 514 final _TIMEOUT = 30000; |
| 515 |
| 512 /** | 516 /** |
| 513 * Runs all the scheduled events for a test case. This should only be called | 517 * Runs all the scheduled events for a test case. This should only be called |
| 514 * once per test case. | 518 * once per test case. |
| 515 */ | 519 */ |
| 516 void run() { | 520 void run() { |
| 517 var createdSandboxDir; | 521 var createdSandboxDir; |
| 518 | 522 |
| 519 var asyncDone = expectAsync0(() {}); | 523 var asyncDone = expectAsync0(() {}); |
| 520 | 524 |
| 521 Future cleanup() { | 525 Future cleanup() { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 542 subFuture.handleException((e) { | 546 subFuture.handleException((e) { |
| 543 print("Exception while cleaning up: $e"); | 547 print("Exception while cleaning up: $e"); |
| 544 print(subFuture.stackTrace); | 548 print(subFuture.stackTrace); |
| 545 registerException(error, subFuture.stackTrace); | 549 registerException(error, subFuture.stackTrace); |
| 546 return true; | 550 return true; |
| 547 }); | 551 }); |
| 548 subFuture.then((_) => registerException(error, future.stackTrace)); | 552 subFuture.then((_) => registerException(error, future.stackTrace)); |
| 549 return true; | 553 return true; |
| 550 }); | 554 }); |
| 551 | 555 |
| 552 future.chain((_) => cleanup()).then((_) { | 556 timeout(future, _TIMEOUT, 'waiting for a test to complete') |
| 553 asyncDone(); | 557 .chain((_) => cleanup()) |
| 554 }); | 558 .then((_) => asyncDone()); |
| 555 } | 559 } |
| 556 | 560 |
| 557 /// Get the path to the root "util/test/pub" directory containing the pub tests. | 561 /// Get the path to the root "util/test/pub" directory containing the pub tests. |
| 558 String get testDirectory { | 562 String get testDirectory { |
| 559 var dir = new Options().script; | 563 var dir = new Options().script; |
| 560 while (basename(dir) != 'pub') dir = dirname(dir); | 564 while (basename(dir) != 'pub') dir = dirname(dir); |
| 561 | 565 |
| 562 return getFullPath(dir); | 566 return getFullPath(dir); |
| 563 } | 567 } |
| 564 | 568 |
| (...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1666 /// calling [completion] is unnecessary. | 1670 /// calling [completion] is unnecessary. |
| 1667 void expectLater(Future actual, matcher, {String reason, | 1671 void expectLater(Future actual, matcher, {String reason, |
| 1668 FailureHandler failureHandler, bool verbose: false}) { | 1672 FailureHandler failureHandler, bool verbose: false}) { |
| 1669 _schedule((_) { | 1673 _schedule((_) { |
| 1670 return actual.transform((value) { | 1674 return actual.transform((value) { |
| 1671 expect(value, matcher, reason: reason, failureHandler: failureHandler, | 1675 expect(value, matcher, reason: reason, failureHandler: failureHandler, |
| 1672 verbose: false); | 1676 verbose: false); |
| 1673 }); | 1677 }); |
| 1674 }); | 1678 }); |
| 1675 } | 1679 } |
| OLD | NEW |