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 /// 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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 bool _abortScheduled = false; | 455 bool _abortScheduled = false; |
456 | 456 |
457 /// The time (in milliseconds) to wait for the entire scheduled test to | 457 /// The time (in milliseconds) to wait for the entire scheduled test to |
458 /// complete. | 458 /// complete. |
459 final _TIMEOUT = 30000; | 459 final _TIMEOUT = 30000; |
460 | 460 |
461 /// Defines an integration test. The [body] should schedule a series of | 461 /// Defines an integration test. The [body] should schedule a series of |
462 /// operations which will be run asynchronously. | 462 /// operations which will be run asynchronously. |
463 void integration(String description, void body()) { | 463 void integration(String description, void body()) { |
464 test(description, () { | 464 test(description, () { |
465 // Sanity check. Make sure we cleaned up the last test. | |
466 assert(_scheduled == null); | |
467 assert(_scheduledCleanup == null); | |
468 assert(_scheduledOnException == null); | |
469 | |
470 // Schedule the test. | 465 // Schedule the test. |
471 body(); | 466 body(); |
472 | 467 |
473 // Run all of the scheduled tasks. If an error occurs, it will propagate | 468 // Run all of the scheduled tasks. If an error occurs, it will propagate |
474 // through the futures back up to here where we can hand it off to unittest. | 469 // through the futures back up to here where we can hand it off to unittest. |
475 var asyncDone = expectAsync0(() {}); | 470 var asyncDone = expectAsync0(() {}); |
476 var createdSandboxDir; | 471 var createdSandboxDir; |
477 _setUpSandbox().then((sandboxDir) { | 472 _setUpSandbox().then((sandboxDir) { |
478 createdSandboxDir = sandboxDir; | 473 createdSandboxDir = sandboxDir; |
479 return timeout(_runScheduled(sandboxDir, _scheduled), | 474 return timeout(_runScheduled(sandboxDir, _scheduled), |
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1555 /// calling [completion] is unnecessary. | 1550 /// calling [completion] is unnecessary. |
1556 void expectLater(Future actual, matcher, {String reason, | 1551 void expectLater(Future actual, matcher, {String reason, |
1557 FailureHandler failureHandler, bool verbose: false}) { | 1552 FailureHandler failureHandler, bool verbose: false}) { |
1558 _schedule((_) { | 1553 _schedule((_) { |
1559 return actual.then((value) { | 1554 return actual.then((value) { |
1560 expect(value, matcher, reason: reason, failureHandler: failureHandler, | 1555 expect(value, matcher, reason: reason, failureHandler: failureHandler, |
1561 verbose: false); | 1556 verbose: false); |
1562 }); | 1557 }); |
1563 }); | 1558 }); |
1564 } | 1559 } |
OLD | NEW |