| 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 // TODO(gram): | 5 // TODO(gram): |
| 6 // Unfortunately I can't seem to test anything that involves timeouts, e.g. | 6 // Unfortunately I can't seem to test anything that involves timeouts, e.g. |
| 7 // insufficient callbacks, because the timeout is controlled externally | 7 // insufficient callbacks, because the timeout is controlled externally |
| 8 // (test.dart?), and we would need to use a shorter timeout for the inner tests | 8 // (test.dart?), and we would need to use a shorter timeout for the inner tests |
| 9 // so the outer timeout doesn't fire. So I removed all such tests. | 9 // so the outer timeout doesn't fire. So I removed all such tests. |
| 10 // I'd like to revisit this at some point. | 10 // I'd like to revisit this at some point. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 class TestConfiguration extends Configuration { | 55 class TestConfiguration extends Configuration { |
| 56 | 56 |
| 57 // Some test state that is captured | 57 // Some test state that is captured |
| 58 int count = 0; // a count of callbacks | 58 int count = 0; // a count of callbacks |
| 59 String setup = ''; // the name of the test group setup function, if any | 59 String setup = ''; // the name of the test group setup function, if any |
| 60 String teardown = ''; // the name of the test group teardown function, if any | 60 String teardown = ''; // the name of the test group teardown function, if any |
| 61 | 61 |
| 62 // The port to communicate with the parent isolate | 62 // The port to communicate with the parent isolate |
| 63 SendPort _port; | 63 SendPort _port; |
| 64 String _result; |
| 64 | 65 |
| 65 TestConfiguration(this._port); | 66 TestConfiguration(this._port); |
| 66 | 67 |
| 67 void onDone(int passed, int failed, int errors, List<TestCase> results, | 68 void onSummary(int passed, int failed, int errors, List<TestCase> results, |
| 68 String uncaughtError) { | 69 String uncaughtError) { |
| 69 var result = buildStatusString(passed, failed, errors, results, | 70 _result = buildStatusString(passed, failed, errors, results, |
| 70 count: count, setup: setup, teardown: teardown, | 71 count: count, setup: setup, teardown: teardown, |
| 71 uncaughtError: uncaughtError); | 72 uncaughtError: uncaughtError); |
| 72 _port.send(result); | 73 } |
| 74 |
| 75 void onDone(bool success) { |
| 76 _port.send(_result); |
| 73 } | 77 } |
| 74 } | 78 } |
| 75 runTest() { | 79 runTest() { |
| 76 port.receive((testName, sendport) { | 80 port.receive((testName, sendport) { |
| 77 configure(_testconfig = new TestConfiguration(sendport)); | 81 configure(_testconfig = new TestConfiguration(sendport)); |
| 78 if (testName == 'single correct test') { | 82 if (testName == 'single correct test') { |
| 79 test(testName, () => expect(2 + 3, equals(5))); | 83 test(testName, () => expect(2 + 3, equals(5))); |
| 80 } else if (testName == 'single failing test') { | 84 } else if (testName == 'single failing test') { |
| 81 test(testName, () => expect(2 + 2, equals(5))); | 85 test(testName, () => expect(2 + 2, equals(5))); |
| 82 } else if (testName == 'exception test') { | 86 } else if (testName == 'exception test') { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 buildStatusString(0, 1, 0, tests[10], message: 'Caught error!'), | 207 buildStatusString(0, 1, 0, tests[10], message: 'Caught error!'), |
| 204 buildStatusString(1, 0, 1, 'testOne', message: 'Callback called after alread
y being marked as done (1).:testTwo:'), | 208 buildStatusString(1, 0, 1, 'testOne', message: 'Callback called after alread
y being marked as done (1).:testTwo:'), |
| 205 buildStatusString(2, 1, 0, 'testOne::testTwo:Expected: false but: was <true>
.:testThree') | 209 buildStatusString(2, 1, 0, 'testOne::testTwo:Expected: false but: was <true>
.:testThree') |
| 206 ]; | 210 ]; |
| 207 | 211 |
| 208 actual = []; | 212 actual = []; |
| 209 | 213 |
| 210 nextTest(0); | 214 nextTest(0); |
| 211 } | 215 } |
| 212 | 216 |
| OLD | NEW |