| 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 @TestOn("vm") | 5 @TestOn("vm") |
| 6 | 6 |
| 7 import 'package:scheduled_test/descriptor.dart' as d; | 7 import 'package:scheduled_test/descriptor.dart' as d; |
| 8 import 'package:scheduled_test/scheduled_stream.dart'; | 8 import 'package:scheduled_test/scheduled_stream.dart'; |
| 9 import 'package:scheduled_test/scheduled_test.dart'; | 9 import 'package:scheduled_test/scheduled_test.dart'; |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 test("a test file fails to compile", () { | 33 test("a test file fails to compile", () { |
| 34 d.file("test.dart", "invalid Dart file").create(); | 34 d.file("test.dart", "invalid Dart file").create(); |
| 35 var test = runTest(["-p", "chrome", "test.dart"]); | 35 var test = runTest(["-p", "chrome", "test.dart"]); |
| 36 | 36 |
| 37 test.stdout.expect(containsInOrder([ | 37 test.stdout.expect(containsInOrder([ |
| 38 "Expected a declaration, but got 'invalid'", | 38 "Expected a declaration, but got 'invalid'", |
| 39 '-1: compiling test.dart', | 39 '-1: compiling test.dart', |
| 40 'Failed to load "test.dart": dart2js failed.' | 40 'Failed to load "test.dart": dart2js failed.' |
| 41 ])); | 41 ])); |
| 42 test.shouldExit(1); | 42 test.shouldExit(1); |
| 43 }); | 43 }, tags: 'chrome'); |
| 44 | 44 |
| 45 test("a test file throws", () { | 45 test("a test file throws", () { |
| 46 d.file("test.dart", "void main() => throw 'oh no';").create(); | 46 d.file("test.dart", "void main() => throw 'oh no';").create(); |
| 47 | 47 |
| 48 var test = runTest(["-p", "chrome", "test.dart"]); | 48 var test = runTest(["-p", "chrome", "test.dart"]); |
| 49 test.stdout.expect(containsInOrder([ | 49 test.stdout.expect(containsInOrder([ |
| 50 '-1: compiling test.dart', | 50 '-1: compiling test.dart', |
| 51 'Failed to load "test.dart": oh no' | 51 'Failed to load "test.dart": oh no' |
| 52 ])); | 52 ])); |
| 53 test.shouldExit(1); | 53 test.shouldExit(1); |
| 54 }); | 54 }, tags: 'chrome'); |
| 55 | 55 |
| 56 test("a test file doesn't have a main defined", () { | 56 test("a test file doesn't have a main defined", () { |
| 57 d.file("test.dart", "void foo() {}").create(); | 57 d.file("test.dart", "void foo() {}").create(); |
| 58 | 58 |
| 59 var test = runTest(["-p", "chrome", "test.dart"]); | 59 var test = runTest(["-p", "chrome", "test.dart"]); |
| 60 test.stdout.expect(containsInOrder([ | 60 test.stdout.expect(containsInOrder([ |
| 61 '-1: compiling test.dart', | 61 '-1: compiling test.dart', |
| 62 'Failed to load "test.dart": No top-level main() function defined.' | 62 'Failed to load "test.dart": No top-level main() function defined.' |
| 63 ])); | 63 ])); |
| 64 test.shouldExit(1); | 64 test.shouldExit(1); |
| 65 }); | 65 }, tags: 'chrome'); |
| 66 | 66 |
| 67 test("a test file has a non-function main", () { | 67 test("a test file has a non-function main", () { |
| 68 d.file("test.dart", "int main;").create(); | 68 d.file("test.dart", "int main;").create(); |
| 69 | 69 |
| 70 var test = runTest(["-p", "chrome", "test.dart"]); | 70 var test = runTest(["-p", "chrome", "test.dart"]); |
| 71 test.stdout.expect(containsInOrder([ | 71 test.stdout.expect(containsInOrder([ |
| 72 '-1: compiling test.dart', | 72 '-1: compiling test.dart', |
| 73 'Failed to load "test.dart": Top-level main getter is not a function.' | 73 'Failed to load "test.dart": Top-level main getter is not a function.' |
| 74 ])); | 74 ])); |
| 75 test.shouldExit(1); | 75 test.shouldExit(1); |
| 76 }); | 76 }, tags: 'chrome'); |
| 77 | 77 |
| 78 test("a test file has a main with arguments", () { | 78 test("a test file has a main with arguments", () { |
| 79 d.file("test.dart", "void main(arg) {}").create(); | 79 d.file("test.dart", "void main(arg) {}").create(); |
| 80 | 80 |
| 81 var test = runTest(["-p", "chrome", "test.dart"]); | 81 var test = runTest(["-p", "chrome", "test.dart"]); |
| 82 test.stdout.expect(containsInOrder([ | 82 test.stdout.expect(containsInOrder([ |
| 83 '-1: compiling test.dart', | 83 '-1: compiling test.dart', |
| 84 'Failed to load "test.dart": Top-level main() function takes arguments.' | 84 'Failed to load "test.dart": Top-level main() function takes arguments.' |
| 85 ])); | 85 ])); |
| 86 test.shouldExit(1); | 86 test.shouldExit(1); |
| 87 }); | 87 }, tags: 'chrome'); |
| 88 | 88 |
| 89 test("a custom HTML file has no script tag", () { | 89 test("a custom HTML file has no script tag", () { |
| 90 d.file("test.dart", "void main() {}").create(); | 90 d.file("test.dart", "void main() {}").create(); |
| 91 | 91 |
| 92 d.file("test.html", """ | 92 d.file("test.html", """ |
| 93 <html> | 93 <html> |
| 94 <head> | 94 <head> |
| 95 <link rel="x-dart-test" href="test.dart"> | 95 <link rel="x-dart-test" href="test.dart"> |
| 96 </head> | 96 </head> |
| 97 </html> | 97 </html> |
| 98 """).create(); | 98 """).create(); |
| 99 | 99 |
| 100 var test = runTest(["-p", "content-shell", "test.dart"]); | 100 var test = runTest(["-p", "content-shell", "test.dart"]); |
| 101 test.stdout.expect(containsInOrder([ | 101 test.stdout.expect(containsInOrder([ |
| 102 '-1: loading test.dart', | 102 '-1: loading test.dart', |
| 103 'Failed to load "test.dart": "test.html" must contain ' | 103 'Failed to load "test.dart": "test.html" must contain ' |
| 104 '<script src="packages/test/dart.js"></script>.' | 104 '<script src="packages/test/dart.js"></script>.' |
| 105 ])); | 105 ])); |
| 106 test.shouldExit(1); | 106 test.shouldExit(1); |
| 107 }); | 107 }, tags: 'content-shell'); |
| 108 | 108 |
| 109 test("a custom HTML file has no link", () { | 109 test("a custom HTML file has no link", () { |
| 110 d.file("test.dart", "void main() {}").create(); | 110 d.file("test.dart", "void main() {}").create(); |
| 111 | 111 |
| 112 d.file("test.html", """ | 112 d.file("test.html", """ |
| 113 <html> | 113 <html> |
| 114 <head> | 114 <head> |
| 115 <script src="packages/test/dart.js"></script> | 115 <script src="packages/test/dart.js"></script> |
| 116 </head> | 116 </head> |
| 117 </html> | 117 </html> |
| 118 """).create(); | 118 """).create(); |
| 119 | 119 |
| 120 var test = runTest(["-p", "content-shell", "test.dart"]); | 120 var test = runTest(["-p", "content-shell", "test.dart"]); |
| 121 test.stdout.expect(containsInOrder([ | 121 test.stdout.expect(containsInOrder([ |
| 122 '-1: loading test.dart', | 122 '-1: loading test.dart', |
| 123 'Failed to load "test.dart": Expected exactly 1 ' | 123 'Failed to load "test.dart": Expected exactly 1 ' |
| 124 '<link rel="x-dart-test"> in test.html, found 0.' | 124 '<link rel="x-dart-test"> in test.html, found 0.' |
| 125 ])); | 125 ])); |
| 126 test.shouldExit(1); | 126 test.shouldExit(1); |
| 127 }); | 127 }, tags: 'content-shell'); |
| 128 | 128 |
| 129 test("a custom HTML file has too many links", () { | 129 test("a custom HTML file has too many links", () { |
| 130 d.file("test.dart", "void main() {}").create(); | 130 d.file("test.dart", "void main() {}").create(); |
| 131 | 131 |
| 132 d.file("test.html", """ | 132 d.file("test.html", """ |
| 133 <html> | 133 <html> |
| 134 <head> | 134 <head> |
| 135 <link rel='x-dart-test' href='test.dart'> | 135 <link rel='x-dart-test' href='test.dart'> |
| 136 <link rel='x-dart-test' href='test.dart'> | 136 <link rel='x-dart-test' href='test.dart'> |
| 137 <script src="packages/test/dart.js"></script> | 137 <script src="packages/test/dart.js"></script> |
| 138 </head> | 138 </head> |
| 139 </html> | 139 </html> |
| 140 """).create(); | 140 """).create(); |
| 141 | 141 |
| 142 var test = runTest(["-p", "content-shell", "test.dart"]); | 142 var test = runTest(["-p", "content-shell", "test.dart"]); |
| 143 test.stdout.expect(containsInOrder([ | 143 test.stdout.expect(containsInOrder([ |
| 144 '-1: loading test.dart', | 144 '-1: loading test.dart', |
| 145 'Failed to load "test.dart": Expected exactly 1 ' | 145 'Failed to load "test.dart": Expected exactly 1 ' |
| 146 '<link rel="x-dart-test"> in test.html, found 2.' | 146 '<link rel="x-dart-test"> in test.html, found 2.' |
| 147 ])); | 147 ])); |
| 148 test.shouldExit(1); | 148 test.shouldExit(1); |
| 149 }); | 149 }, tags: 'content-shell'); |
| 150 | 150 |
| 151 test("a custom HTML file has no href in the link", () { | 151 test("a custom HTML file has no href in the link", () { |
| 152 d.file("test.dart", "void main() {}").create(); | 152 d.file("test.dart", "void main() {}").create(); |
| 153 | 153 |
| 154 d.file("test.html", """ | 154 d.file("test.html", """ |
| 155 <html> | 155 <html> |
| 156 <head> | 156 <head> |
| 157 <link rel='x-dart-test'> | 157 <link rel='x-dart-test'> |
| 158 <script src="packages/test/dart.js"></script> | 158 <script src="packages/test/dart.js"></script> |
| 159 </head> | 159 </head> |
| 160 </html> | 160 </html> |
| 161 """).create(); | 161 """).create(); |
| 162 | 162 |
| 163 var test = runTest(["-p", "content-shell", "test.dart"]); | 163 var test = runTest(["-p", "content-shell", "test.dart"]); |
| 164 test.stdout.expect(containsInOrder([ | 164 test.stdout.expect(containsInOrder([ |
| 165 '-1: loading test.dart', | 165 '-1: loading test.dart', |
| 166 'Failed to load "test.dart": Expected <link rel="x-dart-test"> in ' | 166 'Failed to load "test.dart": Expected <link rel="x-dart-test"> in ' |
| 167 'test.html to have an "href" attribute.' | 167 'test.html to have an "href" attribute.' |
| 168 ])); | 168 ])); |
| 169 test.shouldExit(1); | 169 test.shouldExit(1); |
| 170 }); | 170 }, tags: 'content-shell'); |
| 171 | 171 |
| 172 test("a custom HTML file has an invalid test URL", () { | 172 test("a custom HTML file has an invalid test URL", () { |
| 173 d.file("test.dart", "void main() {}").create(); | 173 d.file("test.dart", "void main() {}").create(); |
| 174 | 174 |
| 175 d.file("test.html", """ | 175 d.file("test.html", """ |
| 176 <html> | 176 <html> |
| 177 <head> | 177 <head> |
| 178 <link rel='x-dart-test' href='wrong.dart'> | 178 <link rel='x-dart-test' href='wrong.dart'> |
| 179 <script src="packages/test/dart.js"></script> | 179 <script src="packages/test/dart.js"></script> |
| 180 </head> | 180 </head> |
| 181 </html> | 181 </html> |
| 182 """).create(); | 182 """).create(); |
| 183 | 183 |
| 184 var test = runTest(["-p", "content-shell", "test.dart"]); | 184 var test = runTest(["-p", "content-shell", "test.dart"]); |
| 185 test.stdout.expect(containsInOrder([ | 185 test.stdout.expect(containsInOrder([ |
| 186 '-1: loading test.dart', | 186 '-1: loading test.dart', |
| 187 'Failed to load "test.dart": Failed to load script at ' | 187 'Failed to load "test.dart": Failed to load script at ' |
| 188 ])); | 188 ])); |
| 189 test.shouldExit(1); | 189 test.shouldExit(1); |
| 190 }); | 190 }, tags: 'content-shell'); |
| 191 | 191 |
| 192 // TODO(nweiz): test what happens when a test file is unreadable once issue | 192 // TODO(nweiz): test what happens when a test file is unreadable once issue |
| 193 // 15078 is fixed. | 193 // 15078 is fixed. |
| 194 }); | 194 }); |
| 195 | 195 |
| 196 group("runs successful tests", () { | 196 group("runs successful tests", () { |
| 197 test("on a JS and non-JS browser", () { | 197 test("on a JS and non-JS browser", () { |
| 198 d.file("test.dart", _success).create(); | 198 d.file("test.dart", _success).create(); |
| 199 var test = runTest(["-p", "content-shell", "-p", "chrome", "test.dart"]); | 199 var test = runTest(["-p", "content-shell", "-p", "chrome", "test.dart"]); |
| 200 | 200 |
| 201 test.stdout.fork().expect(consumeThrough(contains("[Chrome] compiling"))); | 201 test.stdout.fork().expect(consumeThrough(contains("[Chrome] compiling"))); |
| 202 test.stdout.expect(never(contains("[Dartium Content Shell] compiling"))); | 202 test.stdout.expect(never(contains("[Dartium Content Shell] compiling"))); |
| 203 test.shouldExit(0); | 203 test.shouldExit(0); |
| 204 }); | 204 }, tags: ['chrome', 'content-shell']); |
| 205 | 205 |
| 206 test("on a browser and the VM", () { | 206 test("on a browser and the VM", () { |
| 207 d.file("test.dart", _success).create(); | 207 d.file("test.dart", _success).create(); |
| 208 var test = runTest(["-p", "content-shell", "-p", "vm", "test.dart"]); | 208 var test = runTest(["-p", "content-shell", "-p", "vm", "test.dart"]); |
| 209 | 209 |
| 210 test.stdout.expect(consumeThrough(contains("+2: All tests passed!"))); | 210 test.stdout.expect(consumeThrough(contains("+2: All tests passed!"))); |
| 211 test.shouldExit(0); | 211 test.shouldExit(0); |
| 212 }); | 212 }, tags: 'content-shell'); |
| 213 | 213 |
| 214 test("with setUpAll", () { | 214 test("with setUpAll", () { |
| 215 d.file("test.dart", r""" | 215 d.file("test.dart", r""" |
| 216 import 'package:test/test.dart'; | 216 import 'package:test/test.dart'; |
| 217 | 217 |
| 218 void main() { | 218 void main() { |
| 219 setUpAll(() => print("in setUpAll")); | 219 setUpAll(() => print("in setUpAll")); |
| 220 | 220 |
| 221 test("test", () {}); | 221 test("test", () {}); |
| 222 } | 222 } |
| 223 """).create(); | 223 """).create(); |
| 224 | 224 |
| 225 var test = runTest(["-p", "content-shell", "test.dart"]); | 225 var test = runTest(["-p", "content-shell", "test.dart"]); |
| 226 test.stdout.expect(consumeThrough(contains('+0: (setUpAll)'))); | 226 test.stdout.expect(consumeThrough(contains('+0: (setUpAll)'))); |
| 227 test.stdout.expect('in setUpAll'); | 227 test.stdout.expect('in setUpAll'); |
| 228 test.shouldExit(0); | 228 test.shouldExit(0); |
| 229 }); | 229 }, tags: 'content-shell'); |
| 230 | 230 |
| 231 test("with tearDownAll", () { | 231 test("with tearDownAll", () { |
| 232 d.file("test.dart", r""" | 232 d.file("test.dart", r""" |
| 233 import 'package:test/test.dart'; | 233 import 'package:test/test.dart'; |
| 234 | 234 |
| 235 void main() { | 235 void main() { |
| 236 tearDownAll(() => print("in tearDownAll")); | 236 tearDownAll(() => print("in tearDownAll")); |
| 237 | 237 |
| 238 test("test", () {}); | 238 test("test", () {}); |
| 239 } | 239 } |
| 240 """).create(); | 240 """).create(); |
| 241 | 241 |
| 242 var test = runTest(["-p", "content-shell", "test.dart"]); | 242 var test = runTest(["-p", "content-shell", "test.dart"]); |
| 243 test.stdout.expect(consumeThrough(contains('+1: (tearDownAll)'))); | 243 test.stdout.expect(consumeThrough(contains('+1: (tearDownAll)'))); |
| 244 test.stdout.expect('in tearDownAll'); | 244 test.stdout.expect('in tearDownAll'); |
| 245 test.shouldExit(0); | 245 test.shouldExit(0); |
| 246 }); | 246 }, tags: 'content-shell'); |
| 247 | 247 |
| 248 // Regression test; this broke in 0.12.0-beta.9. | 248 // Regression test; this broke in 0.12.0-beta.9. |
| 249 test("on a file in a subdirectory", () { | 249 test("on a file in a subdirectory", () { |
| 250 d.dir("dir", [d.file("test.dart", _success)]).create(); | 250 d.dir("dir", [d.file("test.dart", _success)]).create(); |
| 251 | 251 |
| 252 var test = runTest(["-p", "chrome", "dir/test.dart"]); | 252 var test = runTest(["-p", "chrome", "dir/test.dart"]); |
| 253 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); | 253 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); |
| 254 test.shouldExit(0); | 254 test.shouldExit(0); |
| 255 }); | 255 }, tags: 'chrome'); |
| 256 | 256 |
| 257 group("with a custom HTML file", () { | 257 group("with a custom HTML file", () { |
| 258 setUp(() { | 258 setUp(() { |
| 259 d.file("test.dart", """ | 259 d.file("test.dart", """ |
| 260 import 'dart:html'; | 260 import 'dart:html'; |
| 261 | 261 |
| 262 import 'package:test/test.dart'; | 262 import 'package:test/test.dart'; |
| 263 | 263 |
| 264 void main() { | 264 void main() { |
| 265 test("success", () { | 265 test("success", () { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 278 <div id="foo"></div> | 278 <div id="foo"></div> |
| 279 </body> | 279 </body> |
| 280 </html> | 280 </html> |
| 281 """).create(); | 281 """).create(); |
| 282 }); | 282 }); |
| 283 | 283 |
| 284 test("on content shell", () { | 284 test("on content shell", () { |
| 285 var test = runTest(["-p", "content-shell", "test.dart"]); | 285 var test = runTest(["-p", "content-shell", "test.dart"]); |
| 286 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); | 286 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); |
| 287 test.shouldExit(0); | 287 test.shouldExit(0); |
| 288 }); | 288 }, tags: 'content-shell'); |
| 289 | 289 |
| 290 test("on Chrome", () { | 290 test("on Chrome", () { |
| 291 var test = runTest(["-p", "chrome", "test.dart"]); | 291 var test = runTest(["-p", "chrome", "test.dart"]); |
| 292 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); | 292 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); |
| 293 test.shouldExit(0); | 293 test.shouldExit(0); |
| 294 }); | 294 }, tags: 'chrome'); |
| 295 | 295 |
| 296 // Regression test for https://github.com/dart-lang/test/issues/82. | 296 // Regression test for https://github.com/dart-lang/test/issues/82. |
| 297 test("ignores irrelevant link tags", () { | 297 test("ignores irrelevant link tags", () { |
| 298 d.file("test.html", """ | 298 d.file("test.html", """ |
| 299 <html> | 299 <html> |
| 300 <head> | 300 <head> |
| 301 <link rel='x-dart-test-not'> | 301 <link rel='x-dart-test-not'> |
| 302 <link rel='other' href='test.dart'> | 302 <link rel='other' href='test.dart'> |
| 303 <link rel='x-dart-test' href='test.dart'> | 303 <link rel='x-dart-test' href='test.dart'> |
| 304 <script src="packages/test/dart.js"></script> | 304 <script src="packages/test/dart.js"></script> |
| 305 </head> | 305 </head> |
| 306 <body> | 306 <body> |
| 307 <div id="foo"></div> | 307 <div id="foo"></div> |
| 308 </body> | 308 </body> |
| 309 </html> | 309 </html> |
| 310 """).create(); | 310 """).create(); |
| 311 | 311 |
| 312 var test = runTest(["-p", "content-shell", "test.dart"]); | 312 var test = runTest(["-p", "content-shell", "test.dart"]); |
| 313 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); | 313 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); |
| 314 test.shouldExit(0); | 314 test.shouldExit(0); |
| 315 }); | 315 }, tags: 'content-shell'); |
| 316 }); | 316 }); |
| 317 }); | 317 }); |
| 318 | 318 |
| 319 group("runs failing tests", () { | 319 group("runs failing tests", () { |
| 320 test("that fail only on the browser", () { | 320 test("that fail only on the browser", () { |
| 321 d.file("test.dart", """ | 321 d.file("test.dart", """ |
| 322 import 'dart:async'; | 322 import 'dart:async'; |
| 323 | 323 |
| 324 import 'package:path/path.dart' as p; | 324 import 'package:path/path.dart' as p; |
| 325 import 'package:test/test.dart'; | 325 import 'package:test/test.dart'; |
| 326 | 326 |
| 327 void main() { | 327 void main() { |
| 328 test("test", () { | 328 test("test", () { |
| 329 if (p.style == p.Style.url) throw new TestFailure("oh no"); | 329 if (p.style == p.Style.url) throw new TestFailure("oh no"); |
| 330 }); | 330 }); |
| 331 } | 331 } |
| 332 """).create(); | 332 """).create(); |
| 333 | 333 |
| 334 var test = runTest(["-p", "content-shell", "-p", "vm", "test.dart"]); | 334 var test = runTest(["-p", "content-shell", "-p", "vm", "test.dart"]); |
| 335 test.stdout.expect(consumeThrough(contains("+1 -1: Some tests failed."))); | 335 test.stdout.expect(consumeThrough(contains("+1 -1: Some tests failed."))); |
| 336 test.shouldExit(1); | 336 test.shouldExit(1); |
| 337 }); | 337 }, tags: 'content-shell'); |
| 338 | 338 |
| 339 test("that fail only on the VM", () { | 339 test("that fail only on the VM", () { |
| 340 d.file("test.dart", """ | 340 d.file("test.dart", """ |
| 341 import 'dart:async'; | 341 import 'dart:async'; |
| 342 | 342 |
| 343 import 'package:path/path.dart' as p; | 343 import 'package:path/path.dart' as p; |
| 344 import 'package:test/test.dart'; | 344 import 'package:test/test.dart'; |
| 345 | 345 |
| 346 void main() { | 346 void main() { |
| 347 test("test", () { | 347 test("test", () { |
| 348 if (p.style != p.Style.url) throw new TestFailure("oh no"); | 348 if (p.style != p.Style.url) throw new TestFailure("oh no"); |
| 349 }); | 349 }); |
| 350 } | 350 } |
| 351 """).create(); | 351 """).create(); |
| 352 | 352 |
| 353 var test = runTest(["-p", "content-shell", "-p", "vm", "test.dart"]); | 353 var test = runTest(["-p", "content-shell", "-p", "vm", "test.dart"]); |
| 354 test.stdout.expect(consumeThrough(contains("+1 -1: Some tests failed."))); | 354 test.stdout.expect(consumeThrough(contains("+1 -1: Some tests failed."))); |
| 355 test.shouldExit(1); | 355 test.shouldExit(1); |
| 356 }); | 356 }, tags: 'content-shell'); |
| 357 | 357 |
| 358 group("with a custom HTML file", () { | 358 group("with a custom HTML file", () { |
| 359 setUp(() { | 359 setUp(() { |
| 360 d.file("test.dart", """ | 360 d.file("test.dart", """ |
| 361 import 'dart:html'; | 361 import 'dart:html'; |
| 362 | 362 |
| 363 import 'package:test/test.dart'; | 363 import 'package:test/test.dart'; |
| 364 | 364 |
| 365 void main() { | 365 void main() { |
| 366 test("failure", () { | 366 test("failure", () { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 379 <div id="foo"></div> | 379 <div id="foo"></div> |
| 380 </body> | 380 </body> |
| 381 </html> | 381 </html> |
| 382 """).create(); | 382 """).create(); |
| 383 }); | 383 }); |
| 384 | 384 |
| 385 test("on content shell", () { | 385 test("on content shell", () { |
| 386 var test = runTest(["-p", "content-shell", "test.dart"]); | 386 var test = runTest(["-p", "content-shell", "test.dart"]); |
| 387 test.stdout.expect(consumeThrough(contains("-1: Some tests failed."))); | 387 test.stdout.expect(consumeThrough(contains("-1: Some tests failed."))); |
| 388 test.shouldExit(1); | 388 test.shouldExit(1); |
| 389 }); | 389 }, tags: 'content-shell'); |
| 390 | 390 |
| 391 test("on Chrome", () { | 391 test("on Chrome", () { |
| 392 var test = runTest(["-p", "chrome", "test.dart"]); | 392 var test = runTest(["-p", "chrome", "test.dart"]); |
| 393 test.stdout.expect(consumeThrough(contains("-1: Some tests failed."))); | 393 test.stdout.expect(consumeThrough(contains("-1: Some tests failed."))); |
| 394 test.shouldExit(1); | 394 test.shouldExit(1); |
| 395 }); | 395 }, tags: 'chrome'); |
| 396 }); | 396 }); |
| 397 }); | 397 }); |
| 398 | 398 |
| 399 test("the compiler uses colors if the test runner uses colors", () { | 399 test("the compiler uses colors if the test runner uses colors", () { |
| 400 d.file("test.dart", "String main() => 12;\n").create(); | 400 d.file("test.dart", "String main() => 12;\n").create(); |
| 401 | 401 |
| 402 var test = runTest(["--color", "-p", "chrome", "test.dart"]); | 402 var test = runTest(["--color", "-p", "chrome", "test.dart"]); |
| 403 test.stdout.expect(consumeThrough(contains('\u001b[35m'))); | 403 test.stdout.expect(consumeThrough(contains('\u001b[35m'))); |
| 404 test.shouldExit(1); | 404 test.shouldExit(1); |
| 405 }); | 405 }, tags: 'chrome'); |
| 406 | 406 |
| 407 test("forwards prints from the browser test", () { | 407 test("forwards prints from the browser test", () { |
| 408 d.file("test.dart", """ | 408 d.file("test.dart", """ |
| 409 import 'dart:async'; | 409 import 'dart:async'; |
| 410 | 410 |
| 411 import 'package:test/test.dart'; | 411 import 'package:test/test.dart'; |
| 412 | 412 |
| 413 void main() { | 413 void main() { |
| 414 test("test", () { | 414 test("test", () { |
| 415 print("Hello,"); | 415 print("Hello,"); |
| 416 return new Future(() => print("world!")); | 416 return new Future(() => print("world!")); |
| 417 }); | 417 }); |
| 418 } | 418 } |
| 419 """).create(); | 419 """).create(); |
| 420 | 420 |
| 421 var test = runTest(["-p", "content-shell", "test.dart"]); | 421 var test = runTest(["-p", "content-shell", "test.dart"]); |
| 422 test.stdout.expect(inOrder([ | 422 test.stdout.expect(inOrder([ |
| 423 consumeThrough("Hello,"), | 423 consumeThrough("Hello,"), |
| 424 "world!" | 424 "world!" |
| 425 ])); | 425 ])); |
| 426 test.shouldExit(0); | 426 test.shouldExit(0); |
| 427 }); | 427 }, tags: 'content-shell'); |
| 428 | 428 |
| 429 test("dartifies stack traces for JS-compiled tests by default", () { | 429 test("dartifies stack traces for JS-compiled tests by default", () { |
| 430 d.file("test.dart", _failure).create(); | 430 d.file("test.dart", _failure).create(); |
| 431 | 431 |
| 432 var test = runTest(["-p", "chrome", "--verbose-trace", "test.dart"]); | 432 var test = runTest(["-p", "chrome", "--verbose-trace", "test.dart"]); |
| 433 test.stdout.expect(containsInOrder([ | 433 test.stdout.expect(containsInOrder([ |
| 434 " main.<fn>", | 434 " main.<fn>", |
| 435 "package:test", | 435 "package:test", |
| 436 "dart:async/zone.dart" | 436 "dart:async/zone.dart" |
| 437 ])); | 437 ])); |
| 438 test.shouldExit(1); | 438 test.shouldExit(1); |
| 439 }); | 439 }, tags: 'chrome'); |
| 440 | 440 |
| 441 test("doesn't dartify stack traces for JS-compiled tests with --js-trace", ()
{ | 441 test("doesn't dartify stack traces for JS-compiled tests with --js-trace", ()
{ |
| 442 d.file("test.dart", _failure).create(); | 442 d.file("test.dart", _failure).create(); |
| 443 | 443 |
| 444 var test = runTest( | 444 var test = runTest( |
| 445 ["-p", "chrome", "--verbose-trace", "--js-trace", "test.dart"]); | 445 ["-p", "chrome", "--verbose-trace", "--js-trace", "test.dart"]); |
| 446 test.stdout.fork().expect(never(endsWith(" main.<fn>"))); | 446 test.stdout.fork().expect(never(endsWith(" main.<fn>"))); |
| 447 test.stdout.fork().expect(never(contains("package:test"))); | 447 test.stdout.fork().expect(never(contains("package:test"))); |
| 448 test.stdout.fork().expect(never(contains("dart:async/zone.dart"))); | 448 test.stdout.fork().expect(never(contains("dart:async/zone.dart"))); |
| 449 test.stdout.expect(consumeThrough(contains("-1: Some tests failed."))); | 449 test.stdout.expect(consumeThrough(contains("-1: Some tests failed."))); |
| 450 test.shouldExit(1); | 450 test.shouldExit(1); |
| 451 }); | 451 }, tags: 'chrome'); |
| 452 | 452 |
| 453 test("respects top-level @Timeout declarations", () { | 453 test("respects top-level @Timeout declarations", () { |
| 454 d.file("test.dart", ''' | 454 d.file("test.dart", ''' |
| 455 @Timeout(const Duration(seconds: 0)) | 455 @Timeout(const Duration(seconds: 0)) |
| 456 | 456 |
| 457 import 'dart:async'; | 457 import 'dart:async'; |
| 458 | 458 |
| 459 import 'package:test/test.dart'; | 459 import 'package:test/test.dart'; |
| 460 | 460 |
| 461 void main() { | 461 void main() { |
| 462 test("timeout", () => new Future.delayed(Duration.ZERO)); | 462 test("timeout", () => new Future.delayed(Duration.ZERO)); |
| 463 } | 463 } |
| 464 ''').create(); | 464 ''').create(); |
| 465 | 465 |
| 466 var test = runTest(["-p", "content-shell", "test.dart"]); | 466 var test = runTest(["-p", "content-shell", "test.dart"]); |
| 467 test.stdout.expect(containsInOrder([ | 467 test.stdout.expect(containsInOrder([ |
| 468 "Test timed out after 0 seconds.", | 468 "Test timed out after 0 seconds.", |
| 469 "-1: Some tests failed." | 469 "-1: Some tests failed." |
| 470 ])); | 470 ])); |
| 471 test.shouldExit(1); | 471 test.shouldExit(1); |
| 472 }); | 472 }, tags: 'content-shell'); |
| 473 | 473 |
| 474 group("with onPlatform", () { | 474 group("with onPlatform", () { |
| 475 test("respects matching Skips", () { | 475 test("respects matching Skips", () { |
| 476 d.file("test.dart", ''' | 476 d.file("test.dart", ''' |
| 477 import 'dart:async'; | 477 import 'dart:async'; |
| 478 | 478 |
| 479 import 'package:test/test.dart'; | 479 import 'package:test/test.dart'; |
| 480 | 480 |
| 481 void main() { | 481 void main() { |
| 482 test("fail", () => throw 'oh no', onPlatform: {"browser": new Skip()}); | 482 test("fail", () => throw 'oh no', onPlatform: {"browser": new Skip()}); |
| 483 } | 483 } |
| 484 ''').create(); | 484 ''').create(); |
| 485 | 485 |
| 486 var test = runTest(["-p", "content-shell", "test.dart"]); | 486 var test = runTest(["-p", "content-shell", "test.dart"]); |
| 487 test.stdout.expect(consumeThrough(contains("+0 ~1: All tests skipped."))); | 487 test.stdout.expect(consumeThrough(contains("+0 ~1: All tests skipped."))); |
| 488 test.shouldExit(0); | 488 test.shouldExit(0); |
| 489 }); | 489 }, tags: 'content-shell'); |
| 490 | 490 |
| 491 test("ignores non-matching Skips", () { | 491 test("ignores non-matching Skips", () { |
| 492 d.file("test.dart", ''' | 492 d.file("test.dart", ''' |
| 493 import 'dart:async'; | 493 import 'dart:async'; |
| 494 | 494 |
| 495 import 'package:test/test.dart'; | 495 import 'package:test/test.dart'; |
| 496 | 496 |
| 497 void main() { | 497 void main() { |
| 498 test("success", () {}, onPlatform: {"vm": new Skip()}); | 498 test("success", () {}, onPlatform: {"vm": new Skip()}); |
| 499 } | 499 } |
| 500 ''').create(); | 500 ''').create(); |
| 501 | 501 |
| 502 var test = runTest(["-p", "content-shell", "test.dart"]); | 502 var test = runTest(["-p", "content-shell", "test.dart"]); |
| 503 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); | 503 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); |
| 504 test.shouldExit(0); | 504 test.shouldExit(0); |
| 505 }); | 505 }, tags: 'content-shell'); |
| 506 | 506 |
| 507 test("respects matching Timeouts", () { | 507 test("respects matching Timeouts", () { |
| 508 d.file("test.dart", ''' | 508 d.file("test.dart", ''' |
| 509 import 'dart:async'; | 509 import 'dart:async'; |
| 510 | 510 |
| 511 import 'package:test/test.dart'; | 511 import 'package:test/test.dart'; |
| 512 | 512 |
| 513 void main() { | 513 void main() { |
| 514 test("fail", () async { | 514 test("fail", () async { |
| 515 await new Future.delayed(Duration.ZERO); | 515 await new Future.delayed(Duration.ZERO); |
| 516 throw 'oh no'; | 516 throw 'oh no'; |
| 517 }, onPlatform: { | 517 }, onPlatform: { |
| 518 "browser": new Timeout(Duration.ZERO) | 518 "browser": new Timeout(Duration.ZERO) |
| 519 }); | 519 }); |
| 520 } | 520 } |
| 521 ''').create(); | 521 ''').create(); |
| 522 | 522 |
| 523 var test = runTest(["-p", "content-shell", "test.dart"]); | 523 var test = runTest(["-p", "content-shell", "test.dart"]); |
| 524 test.stdout.expect(containsInOrder([ | 524 test.stdout.expect(containsInOrder([ |
| 525 "Test timed out after 0 seconds.", | 525 "Test timed out after 0 seconds.", |
| 526 "-1: Some tests failed." | 526 "-1: Some tests failed." |
| 527 ])); | 527 ])); |
| 528 test.shouldExit(1); | 528 test.shouldExit(1); |
| 529 }); | 529 }, tags: 'content-shell'); |
| 530 | 530 |
| 531 test("ignores non-matching Timeouts", () { | 531 test("ignores non-matching Timeouts", () { |
| 532 d.file("test.dart", ''' | 532 d.file("test.dart", ''' |
| 533 import 'dart:async'; | 533 import 'dart:async'; |
| 534 | 534 |
| 535 import 'package:test/test.dart'; | 535 import 'package:test/test.dart'; |
| 536 | 536 |
| 537 void main() { | 537 void main() { |
| 538 test("success", () {}, onPlatform: { | 538 test("success", () {}, onPlatform: { |
| 539 "vm": new Timeout(new Duration(seconds: 0)) | 539 "vm": new Timeout(new Duration(seconds: 0)) |
| 540 }); | 540 }); |
| 541 } | 541 } |
| 542 ''').create(); | 542 ''').create(); |
| 543 | 543 |
| 544 var test = runTest(["-p", "content-shell", "test.dart"]); | 544 var test = runTest(["-p", "content-shell", "test.dart"]); |
| 545 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); | 545 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); |
| 546 test.shouldExit(0); | 546 test.shouldExit(0); |
| 547 }); | 547 }, tags: 'content-shell'); |
| 548 | 548 |
| 549 test("applies matching platforms in order", () { | 549 test("applies matching platforms in order", () { |
| 550 d.file("test.dart", ''' | 550 d.file("test.dart", ''' |
| 551 import 'dart:async'; | 551 import 'dart:async'; |
| 552 | 552 |
| 553 import 'package:test/test.dart'; | 553 import 'package:test/test.dart'; |
| 554 | 554 |
| 555 void main() { | 555 void main() { |
| 556 test("success", () {}, onPlatform: { | 556 test("success", () {}, onPlatform: { |
| 557 "browser": new Skip("first"), | 557 "browser": new Skip("first"), |
| 558 "browser || windows": new Skip("second"), | 558 "browser || windows": new Skip("second"), |
| 559 "browser || linux": new Skip("third"), | 559 "browser || linux": new Skip("third"), |
| 560 "browser || mac-os": new Skip("fourth"), | 560 "browser || mac-os": new Skip("fourth"), |
| 561 "browser || android": new Skip("fifth") | 561 "browser || android": new Skip("fifth") |
| 562 }); | 562 }); |
| 563 } | 563 } |
| 564 ''').create(); | 564 ''').create(); |
| 565 | 565 |
| 566 var test = runTest(["-p", "content-shell", "test.dart"]); | 566 var test = runTest(["-p", "content-shell", "test.dart"]); |
| 567 test.stdout.fork().expect(never(contains("Skip: first"))); | 567 test.stdout.fork().expect(never(contains("Skip: first"))); |
| 568 test.stdout.fork().expect(never(contains("Skip: second"))); | 568 test.stdout.fork().expect(never(contains("Skip: second"))); |
| 569 test.stdout.fork().expect(never(contains("Skip: third"))); | 569 test.stdout.fork().expect(never(contains("Skip: third"))); |
| 570 test.stdout.fork().expect(never(contains("Skip: fourth"))); | 570 test.stdout.fork().expect(never(contains("Skip: fourth"))); |
| 571 test.stdout.expect(consumeThrough(contains("Skip: fifth"))); | 571 test.stdout.expect(consumeThrough(contains("Skip: fifth"))); |
| 572 test.shouldExit(0); | 572 test.shouldExit(0); |
| 573 }); | 573 }, tags: 'content-shell'); |
| 574 }); | 574 }); |
| 575 | 575 |
| 576 group("with an @OnPlatform annotation", () { | 576 group("with an @OnPlatform annotation", () { |
| 577 test("respects matching Skips", () { | 577 test("respects matching Skips", () { |
| 578 d.file("test.dart", ''' | 578 d.file("test.dart", ''' |
| 579 @OnPlatform(const {"browser": const Skip()}) | 579 @OnPlatform(const {"browser": const Skip()}) |
| 580 | 580 |
| 581 import 'dart:async'; | 581 import 'dart:async'; |
| 582 | 582 |
| 583 import 'package:test/test.dart'; | 583 import 'package:test/test.dart'; |
| 584 | 584 |
| 585 void main() { | 585 void main() { |
| 586 test("fail", () => throw 'oh no'); | 586 test("fail", () => throw 'oh no'); |
| 587 } | 587 } |
| 588 ''').create(); | 588 ''').create(); |
| 589 | 589 |
| 590 var test = runTest(["-p", "content-shell", "test.dart"]); | 590 var test = runTest(["-p", "content-shell", "test.dart"]); |
| 591 test.stdout.expect(consumeThrough(contains("~1: All tests skipped."))); | 591 test.stdout.expect(consumeThrough(contains("~1: All tests skipped."))); |
| 592 test.shouldExit(0); | 592 test.shouldExit(0); |
| 593 }); | 593 }, tags: 'content-shell'); |
| 594 | 594 |
| 595 test("ignores non-matching Skips", () { | 595 test("ignores non-matching Skips", () { |
| 596 d.file("test.dart", ''' | 596 d.file("test.dart", ''' |
| 597 @OnPlatform(const {"vm": const Skip()}) | 597 @OnPlatform(const {"vm": const Skip()}) |
| 598 | 598 |
| 599 import 'dart:async'; | 599 import 'dart:async'; |
| 600 | 600 |
| 601 import 'package:test/test.dart'; | 601 import 'package:test/test.dart'; |
| 602 | 602 |
| 603 void main() { | 603 void main() { |
| 604 test("success", () {}); | 604 test("success", () {}); |
| 605 } | 605 } |
| 606 ''').create(); | 606 ''').create(); |
| 607 | 607 |
| 608 var test = runTest(["-p", "content-shell", "test.dart"]); | 608 var test = runTest(["-p", "content-shell", "test.dart"]); |
| 609 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); | 609 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); |
| 610 test.shouldExit(0); | 610 test.shouldExit(0); |
| 611 }); | 611 }, tags: 'content-shell'); |
| 612 | 612 |
| 613 test("respects matching Timeouts", () { | 613 test("respects matching Timeouts", () { |
| 614 d.file("test.dart", ''' | 614 d.file("test.dart", ''' |
| 615 @OnPlatform(const { | 615 @OnPlatform(const { |
| 616 "browser": const Timeout(const Duration(seconds: 0)) | 616 "browser": const Timeout(const Duration(seconds: 0)) |
| 617 }) | 617 }) |
| 618 | 618 |
| 619 import 'dart:async'; | 619 import 'dart:async'; |
| 620 | 620 |
| 621 import 'package:test/test.dart'; | 621 import 'package:test/test.dart'; |
| 622 | 622 |
| 623 void main() { | 623 void main() { |
| 624 test("fail", () async { | 624 test("fail", () async { |
| 625 await new Future.delayed(Duration.ZERO); | 625 await new Future.delayed(Duration.ZERO); |
| 626 throw 'oh no'; | 626 throw 'oh no'; |
| 627 }); | 627 }); |
| 628 } | 628 } |
| 629 ''').create(); | 629 ''').create(); |
| 630 | 630 |
| 631 var test = runTest(["-p", "content-shell", "test.dart"]); | 631 var test = runTest(["-p", "content-shell", "test.dart"]); |
| 632 test.stdout.expect(containsInOrder([ | 632 test.stdout.expect(containsInOrder([ |
| 633 "Test timed out after 0 seconds.", | 633 "Test timed out after 0 seconds.", |
| 634 "-1: Some tests failed." | 634 "-1: Some tests failed." |
| 635 ])); | 635 ])); |
| 636 test.shouldExit(1); | 636 test.shouldExit(1); |
| 637 }); | 637 }, tags: 'content-shell'); |
| 638 | 638 |
| 639 test("ignores non-matching Timeouts", () { | 639 test("ignores non-matching Timeouts", () { |
| 640 d.file("test.dart", ''' | 640 d.file("test.dart", ''' |
| 641 @OnPlatform(const { | 641 @OnPlatform(const { |
| 642 "vm": const Timeout(const Duration(seconds: 0)) | 642 "vm": const Timeout(const Duration(seconds: 0)) |
| 643 }) | 643 }) |
| 644 | 644 |
| 645 import 'dart:async'; | 645 import 'dart:async'; |
| 646 | 646 |
| 647 import 'package:test/test.dart'; | 647 import 'package:test/test.dart'; |
| 648 | 648 |
| 649 void main() { | 649 void main() { |
| 650 test("success", () {}); | 650 test("success", () {}); |
| 651 } | 651 } |
| 652 ''').create(); | 652 ''').create(); |
| 653 | 653 |
| 654 var test = runTest(["-p", "content-shell", "test.dart"]); | 654 var test = runTest(["-p", "content-shell", "test.dart"]); |
| 655 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); | 655 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); |
| 656 test.shouldExit(0); | 656 test.shouldExit(0); |
| 657 }); | 657 }, tags: 'content-shell'); |
| 658 }); | 658 }); |
| 659 } | 659 } |
| OLD | NEW |