Chromium Code Reviews| 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 13 matching lines...) Expand all Loading... | |
| 24 final port = new ReceivePort(); | 24 final port = new ReceivePort(); |
| 25 port.receive((msg, reply) { | 25 port.receive((msg, reply) { |
| 26 fn(); | 26 fn(); |
| 27 port.close(); | 27 port.close(); |
| 28 }); | 28 }); |
| 29 port.toSendPort().send(null, null); | 29 port.toSendPort().send(null, null); |
| 30 } | 30 } |
| 31 | 31 |
| 32 String buildStatusString(int passed, int failed, int errors, | 32 String buildStatusString(int passed, int failed, int errors, |
| 33 var results, | 33 var results, |
| 34 [int count = 0, | 34 {int count: 0, |
| 35 String setup = '', String teardown = '', | 35 String setup: '', String teardown: '', |
| 36 String uncaughtError = null, | 36 String uncaughtError: null, |
| 37 String message = '']) { | 37 String message: ''}) { |
|
Bob Nystrom
2012/10/17 16:21:38
Check with Gram, but instead of making these named
regis
2012/10/17 19:58:16
Only 3 out of 14 calls pass a message, so I am not
| |
| 38 var totalTests = 0; | 38 var totalTests = 0; |
| 39 String testDetails = ''; | 39 String testDetails = ''; |
| 40 if (results is String) { | 40 if (results is String) { |
| 41 totalTests = passed + failed + errors; | 41 totalTests = passed + failed + errors; |
| 42 testDetails = ':$results:$message'; | 42 testDetails = ':$results:$message'; |
| 43 } else { | 43 } else { |
| 44 totalTests = results.length; | 44 totalTests = results.length; |
| 45 for (var i = 0; i < results.length; i++) { | 45 for (var i = 0; i < results.length; i++) { |
| 46 testDetails = '$testDetails:${results[i].description}:' | 46 testDetails = '$testDetails:${results[i].description}:' |
| 47 '${collapseWhitespace(results[i].message)}'; | 47 '${collapseWhitespace(results[i].message)}'; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 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 | 64 |
| 65 TestConfiguration(this._port); | 65 TestConfiguration(this._port); |
| 66 | 66 |
| 67 void onDone(int passed, int failed, int errors, List<TestCase> results, | 67 void onDone(int passed, int failed, int errors, List<TestCase> results, |
| 68 String uncaughtError) { | 68 String uncaughtError) { |
| 69 var result = buildStatusString(passed, failed, errors, results, count, | 69 var result = buildStatusString(passed, failed, errors, results, |
| 70 setup, teardown, uncaughtError); | 70 count: count, setup: setup, teardown: teardown, |
| 71 uncaughtError: uncaughtError); | |
| 71 _port.send(result); | 72 _port.send(result); |
| 72 } | 73 } |
| 73 } | 74 } |
| 74 runTest() { | 75 runTest() { |
| 75 port.receive((testName, sendport) { | 76 port.receive((testName, sendport) { |
| 76 configure(_testconfig = new TestConfiguration(sendport)); | 77 configure(_testconfig = new TestConfiguration(sendport)); |
| 77 if (testName == 'single correct test') { | 78 if (testName == 'single correct test') { |
| 78 test(testName, () => expect(2 + 3, equals(5))); | 79 test(testName, () => expect(2 + 3, equals(5))); |
| 79 } else if (testName == 'single failing test') { | 80 } else if (testName == 'single failing test') { |
| 80 test(testName, () => expect(2 + 2, equals(5))); | 81 test(testName, () => expect(2 + 2, equals(5))); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 'late exception test', | 184 'late exception test', |
| 184 'middle exception test' | 185 'middle exception test' |
| 185 ]; | 186 ]; |
| 186 | 187 |
| 187 expected = [ | 188 expected = [ |
| 188 buildStatusString(1, 0, 0, tests[0]), | 189 buildStatusString(1, 0, 0, tests[0]), |
| 189 buildStatusString(0, 1, 0, tests[1], | 190 buildStatusString(0, 1, 0, tests[1], |
| 190 message: 'Expected: <5> but: was <4>.'), | 191 message: 'Expected: <5> but: was <4>.'), |
| 191 buildStatusString(0, 1, 0, tests[2], message: 'Caught Exception: Fail.'), | 192 buildStatusString(0, 1, 0, tests[2], message: 'Caught Exception: Fail.'), |
| 192 buildStatusString(2, 0, 0, 'a a::a b b'), | 193 buildStatusString(2, 0, 0, 'a a::a b b'), |
| 193 buildStatusString(1, 0, 0, 'a ${tests[4]}', 0, 'setup'), | 194 buildStatusString(1, 0, 0, 'a ${tests[4]}', count: 0, setup: 'setup'), |
| 194 buildStatusString(1, 0, 0, 'a ${tests[5]}', 0, '', 'teardown'), | 195 buildStatusString(1, 0, 0, 'a ${tests[5]}', count: 0, setup: '', |
| 195 buildStatusString(1, 0, 0, 'a ${tests[6]}', 0, | 196 teardown: 'teardown'), |
| 196 'setup', 'teardown'), | 197 buildStatusString(1, 0, 0, 'a ${tests[6]}', count: 0, |
| 197 buildStatusString(1, 0, 0, tests[7], 1), | 198 setup: 'setup', teardown: 'teardown'), |
| 198 buildStatusString(0, 0, 1, tests[8], 1, | 199 buildStatusString(1, 0, 0, tests[7], count: 1), |
| 200 buildStatusString(0, 0, 1, tests[8], count: 1, | |
| 199 message: 'Callback called more times than expected (2 > 1).'), | 201 message: 'Callback called more times than expected (2 > 1).'), |
| 200 buildStatusString(1, 0, 0, tests[9], 10), | 202 buildStatusString(1, 0, 0, tests[9], count: 10), |
| 201 buildStatusString(0, 1, 0, tests[10], message: 'Caught error!'), | 203 buildStatusString(0, 1, 0, tests[10], message: 'Caught error!'), |
| 202 buildStatusString(1, 0, 1, 'testOne', message: 'Callback called after alread y being marked as done (1).:testTwo:'), | 204 buildStatusString(1, 0, 1, 'testOne', message: 'Callback called after alread y being marked as done (1).:testTwo:'), |
| 203 buildStatusString(2, 1, 0, 'testOne::testTwo:Expected: false but: was <true> .:testThree') | 205 buildStatusString(2, 1, 0, 'testOne::testTwo:Expected: false but: was <true> .:testThree') |
| 204 ]; | 206 ]; |
| 205 | 207 |
| 206 actual = []; | 208 actual = []; |
| 207 | 209 |
| 208 nextTest(0); | 210 nextTest(0); |
| 209 } | 211 } |
| 210 | 212 |
| OLD | NEW |