Chromium Code Reviews| Index: lib/unittest/shared.dart |
| diff --git a/lib/unittest/shared.dart b/lib/unittest/shared.dart |
| index 56923021565821db5392d78b712f11406aecee19..4a1054c3ed3d0cb2ed3bf9faa459baa2746e8bd8 100644 |
| --- a/lib/unittest/shared.dart |
| +++ b/lib/unittest/shared.dart |
| @@ -2,6 +2,12 @@ |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| +Configuration _config = null; |
| + |
| +void configure(Configuration c) { |
|
Bob Nystrom
2012/04/10 00:30:31
Is anything using this?
Siggi Cherem (dart-lang)
2012/04/10 01:05:28
Not yet, step 2 :) - removed.
|
| + _config = c; |
| +} |
| + |
| /** |
| * Description text of the current test group. If multiple groups are nested, |
| * this will contain all of their text concatenated. |
| @@ -17,9 +23,6 @@ List<TestCase> _tests; |
| */ |
| Function _testRunner; |
| -/** Whether this is run within dartium layout tests. */ |
| -bool _isLayoutTest = false; |
| - |
| /** Current test being executed. */ |
| int _currentTest = 0; |
| @@ -86,21 +89,6 @@ void asyncTest(String spec, int callbacks, TestFunction body) { |
| } |
| } |
| -void serialInvokeAsync(List closures) { |
| - final length = closures.length; |
| - if (length > 0) { |
| - int i = 0; |
| - void invokeNext() { |
| - closures[i](); |
| - i++; |
| - if (i < length) { |
| - window.setTimeout(invokeNext, 0); |
| - } |
| - } |
| - window.setTimeout(invokeNext, 0); |
| - } |
| -} |
| - |
| /** |
| * Creates a new named group of tests. Calls to group() or test() within the |
| * body of the function passed to this will inherit this group's description. |
| @@ -148,15 +136,24 @@ void callbackDone() { |
| } |
| } |
| -void forLayoutTests() { |
| - _isLayoutTest = true; |
| +/** Runs [callback] at the end of the event loop. */ |
| +_defer(void callback()) { |
| + // Exploit isolate ports as a platform-independent mechanism to queue a |
| + // message at the end of the event loop. |
| + // TODO(sigmund): expose this functionality somewhere in our libraries. |
| + final port = new ReceivePort(); |
| + port.receive((msg, reply) { |
| + callback(); |
| + port.close(); |
| + }); |
| + port.toSendPort().send(null, null); |
| } |
| /** Runs all queued tests, one at a time. */ |
| _runTests() { |
| - _platformStartTests(); |
| + _config.onStart(); |
| - _platformDefer(() { |
| + _defer(() { |
| assert (_currentTest == 0); |
| _testRunner(); |
| }); |
| @@ -226,7 +223,7 @@ _completeTests() { |
| } |
| } |
| - _platformCompleteTests(testsPassed_, testsFailed_, testsErrors_); |
| + _config.onDone(testsPassed_, testsFailed_, testsErrors_, _tests); |
| } |
| String _fullSpec(String spec) { |
| @@ -245,11 +242,14 @@ _ensureInitialized() { |
| _state = _READY; |
| _testRunner = _nextBatch; |
| - _platformInitialize(); |
| + if (_config == null) { |
| + _config = _defaultConfig(); |
| + } |
| + _config.onInit(); |
| // Immediately queue the suite up. It will run after a timeout (i.e. after |
| // main() has returned). |
| - _platformDefer(_runTests); |
| + _defer(_runTests); |
| } |
| /** |