| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 import 'dart:io'; | 5 import 'dart:io'; |
| 6 | 6 |
| 7 import 'package:path/path.dart' as p; | 7 import 'package:path/path.dart' as p; |
| 8 import 'package:unittest/src/util/io.dart'; | 8 import 'package:unittest/src/util/io.dart'; |
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 test("runs several failing tests and reports when each fails", () { | 39 test("runs several failing tests and reports when each fails", () { |
| 40 _expectReport(""" | 40 _expectReport(""" |
| 41 test('failure 1', () => throw new TestFailure('oh no')); | 41 test('failure 1', () => throw new TestFailure('oh no')); |
| 42 test('failure 2', () => throw new TestFailure('oh no')); | 42 test('failure 2', () => throw new TestFailure('oh no')); |
| 43 test('failure 3', () => throw new TestFailure('oh no'));""", | 43 test('failure 3', () => throw new TestFailure('oh no'));""", |
| 44 """ | 44 """ |
| 45 +0: failure 1 | 45 +0: failure 1 |
| 46 +0 -1: failure 1 | 46 +0 -1: failure 1 |
| 47 oh no | 47 oh no |
| 48 test.dart 6:33 main.<fn> | 48 test.dart 6:33 main.<fn> |
| 49 dart:isolate _RawReceivePortImpl._handleMessage | |
| 50 | 49 |
| 51 | 50 |
| 52 +0 -1: failure 2 | 51 +0 -1: failure 2 |
| 53 +0 -2: failure 2 | 52 +0 -2: failure 2 |
| 54 oh no | 53 oh no |
| 55 test.dart 7:33 main.<fn> | 54 test.dart 7:33 main.<fn> |
| 56 dart:isolate _RawReceivePortImpl._handleMessage | |
| 57 | 55 |
| 58 | 56 |
| 59 +0 -2: failure 3 | 57 +0 -2: failure 3 |
| 60 +0 -3: failure 3 | 58 +0 -3: failure 3 |
| 61 oh no | 59 oh no |
| 62 test.dart 8:33 main.<fn> | 60 test.dart 8:33 main.<fn> |
| 63 dart:isolate _RawReceivePortImpl._handleMessage | |
| 64 | 61 |
| 65 | 62 |
| 66 +0 -3: Some tests failed."""); | 63 +0 -3: Some tests failed."""); |
| 67 }); | 64 }); |
| 68 | 65 |
| 69 test("runs failing tests along with successful tests", () { | 66 test("runs failing tests along with successful tests", () { |
| 70 _expectReport(""" | 67 _expectReport(""" |
| 71 test('failure 1', () => throw new TestFailure('oh no')); | 68 test('failure 1', () => throw new TestFailure('oh no')); |
| 72 test('success 1', () {}); | 69 test('success 1', () {}); |
| 73 test('failure 2', () => throw new TestFailure('oh no')); | 70 test('failure 2', () => throw new TestFailure('oh no')); |
| 74 test('success 2', () {});""", | 71 test('success 2', () {});""", |
| 75 """ | 72 """ |
| 76 +0: failure 1 | 73 +0: failure 1 |
| 77 +0 -1: failure 1 | 74 +0 -1: failure 1 |
| 78 oh no | 75 oh no |
| 79 test.dart 6:33 main.<fn> | 76 test.dart 6:33 main.<fn> |
| 80 dart:isolate _RawReceivePortImpl._handleMessage | |
| 81 | 77 |
| 82 | 78 |
| 83 +0 -1: success 1 | 79 +0 -1: success 1 |
| 84 +1 -1: success 1 | 80 +1 -1: success 1 |
| 85 +1 -1: failure 2 | 81 +1 -1: failure 2 |
| 86 +1 -2: failure 2 | 82 +1 -2: failure 2 |
| 87 oh no | 83 oh no |
| 88 test.dart 8:33 main.<fn> | 84 test.dart 8:33 main.<fn> |
| 89 dart:isolate _RawReceivePortImpl._handleMessage | |
| 90 | 85 |
| 91 | 86 |
| 92 +1 -2: success 2 | 87 +1 -2: success 2 |
| 93 +2 -2: success 2 | 88 +2 -2: success 2 |
| 94 +2 -2: Some tests failed."""); | 89 +2 -2: Some tests failed."""); |
| 95 }); | 90 }); |
| 96 | 91 |
| 97 test("gracefully handles multiple test failures in a row", () { | 92 test("gracefully handles multiple test failures in a row", () { |
| 98 _expectReport(""" | 93 _expectReport(""" |
| 99 // This completer ensures that the test isolate isn't killed until all | 94 // This completer ensures that the test isolate isn't killed until all |
| 100 // errors have been thrown. | 95 // errors have been thrown. |
| 101 var completer = new Completer(); | 96 var completer = new Completer(); |
| 102 test('failures', () { | 97 test('failures', () { |
| 103 new Future.microtask(() => throw 'first error'); | 98 new Future.microtask(() => throw 'first error'); |
| 104 new Future.microtask(() => throw 'second error'); | 99 new Future.microtask(() => throw 'second error'); |
| 105 new Future.microtask(() => throw 'third error'); | 100 new Future.microtask(() => throw 'third error'); |
| 106 new Future.microtask(completer.complete); | 101 new Future.microtask(completer.complete); |
| 107 }); | 102 }); |
| 108 test('wait', () => completer.future);""", | 103 test('wait', () => completer.future);""", |
| 109 """ | 104 """ |
| 110 +0: failures | 105 +0: failures |
| 111 +0 -1: failures | 106 +0 -1: failures |
| 112 first error | 107 first error |
| 113 test.dart 10:38 main.<fn>.<fn> | 108 test.dart 10:38 main.<fn>.<fn> |
| 114 dart:isolate _RawReceivePortImpl._handleMessage | |
| 115 ===== asynchronous gap =========================== | 109 ===== asynchronous gap =========================== |
| 116 dart:async Future.Future.microtask | 110 dart:async Future.Future.microtask |
| 117 test.dart 10:15 main.<fn> | 111 test.dart 10:15 main.<fn> |
| 118 dart:isolate _RawReceivePortImpl._handleMessage | |
| 119 | 112 |
| 120 | 113 |
| 121 second error | 114 second error |
| 122 test.dart 11:38 main.<fn>.<fn> | 115 test.dart 11:38 main.<fn>.<fn> |
| 123 dart:isolate _RawReceivePortImpl._handleMessage | |
| 124 ===== asynchronous gap =========================== | 116 ===== asynchronous gap =========================== |
| 125 dart:async Future.Future.microtask | 117 dart:async Future.Future.microtask |
| 126 test.dart 11:15 main.<fn> | 118 test.dart 11:15 main.<fn> |
| 127 dart:isolate _RawReceivePortImpl._handleMessage | |
| 128 | 119 |
| 129 | 120 |
| 130 third error | 121 third error |
| 131 test.dart 12:38 main.<fn>.<fn> | 122 test.dart 12:38 main.<fn>.<fn> |
| 132 dart:isolate _RawReceivePortImpl._handleMessage | |
| 133 ===== asynchronous gap =========================== | 123 ===== asynchronous gap =========================== |
| 134 dart:async Future.Future.microtask | 124 dart:async Future.Future.microtask |
| 135 test.dart 12:15 main.<fn> | 125 test.dart 12:15 main.<fn> |
| 136 dart:isolate _RawReceivePortImpl._handleMessage | |
| 137 | 126 |
| 138 | 127 |
| 139 +0 -1: wait | 128 +0 -1: wait |
| 140 +1 -1: wait | 129 +1 -1: wait |
| 141 +1 -1: Some tests failed."""); | 130 +1 -1: Some tests failed."""); |
| 142 }); | 131 }); |
| 143 } | 132 } |
| 144 | 133 |
| 145 final _prefixLength = "XX:XX ".length; | 134 final _prefixLength = "XX:XX ".length; |
| 146 | 135 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 169 // Un-indent the expected string. | 158 // Un-indent the expected string. |
| 170 var indentation = expected.indexOf(new RegExp("[^ ]")); | 159 var indentation = expected.indexOf(new RegExp("[^ ]")); |
| 171 expected = expected.split("\n").map((line) { | 160 expected = expected.split("\n").map((line) { |
| 172 if (line.isEmpty) return line; | 161 if (line.isEmpty) return line; |
| 173 return line.substring(indentation); | 162 return line.substring(indentation); |
| 174 }).join("\n"); | 163 }).join("\n"); |
| 175 | 164 |
| 176 expect(actual, equals(expected)); | 165 expect(actual, equals(expected)); |
| 177 }), completes); | 166 }), completes); |
| 178 } | 167 } |
| OLD | NEW |