Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: test/runner/isolate_listener_test.dart

Issue 1086213002: Support a @Timeout annotation. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: CHANGELOG + README Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/runner/browser/runner_test.dart ('k') | test/runner/parse_metadata_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 'dart:async'; 7 import 'dart:async';
8 import 'dart:isolate'; 8 import 'dart:isolate';
9 9
10 import 'package:test/src/backend/invoker.dart'; 10 import 'package:test/src/backend/invoker.dart';
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 Future<ReceivePort> _spawnIsolate(void entryPoint(SendPort sendPort)) { 298 Future<ReceivePort> _spawnIsolate(void entryPoint(SendPort sendPort)) {
299 var receivePort = new ReceivePort(); 299 var receivePort = new ReceivePort();
300 return Isolate.spawn(entryPoint, receivePort.sendPort).then((isolate) { 300 return Isolate.spawn(entryPoint, receivePort.sendPort).then((isolate) {
301 _isolate = isolate; 301 _isolate = isolate;
302 return receivePort; 302 return receivePort;
303 }); 303 });
304 } 304 }
305 305
306 /// An isolate entrypoint that throws immediately. 306 /// An isolate entrypoint that throws immediately.
307 void _loadError(SendPort sendPort) => 307 void _loadError(SendPort sendPort) =>
308 IsolateListener.start(sendPort, () => () => throw 'oh no'); 308 IsolateListener.start(sendPort, new Metadata(), () => () => throw 'oh no');
309 309
310 /// An isolate entrypoint that throws a NoSuchMethodError. 310 /// An isolate entrypoint that throws a NoSuchMethodError.
311 void _noSuchMethodError(SendPort sendPort) { 311 void _noSuchMethodError(SendPort sendPort) {
312 return IsolateListener.start(sendPort, () => 312 return IsolateListener.start(sendPort, new Metadata(), () =>
313 throw new NoSuchMethodError(null, #main, [], {})); 313 throw new NoSuchMethodError(null, #main, [], {}));
314 } 314 }
315 315
316 /// An isolate entrypoint that returns a non-function. 316 /// An isolate entrypoint that returns a non-function.
317 void _nonFunction(SendPort sendPort) => 317 void _nonFunction(SendPort sendPort) =>
318 IsolateListener.start(sendPort, () => null); 318 IsolateListener.start(sendPort, new Metadata(), () => null);
319 319
320 /// An isolate entrypoint that returns a function with the wrong arity. 320 /// An isolate entrypoint that returns a function with the wrong arity.
321 void _wrongArity(SendPort sendPort) => 321 void _wrongArity(SendPort sendPort) =>
322 IsolateListener.start(sendPort, () => (_) {}); 322 IsolateListener.start(sendPort, new Metadata(), () => (_) {});
323 323
324 /// An isolate entrypoint that defines three tests that succeed. 324 /// An isolate entrypoint that defines three tests that succeed.
325 void _successfulTests(SendPort sendPort) { 325 void _successfulTests(SendPort sendPort) {
326 IsolateListener.start(sendPort, () => () { 326 IsolateListener.start(sendPort, new Metadata(), () => () {
327 test("successful 1", () {}); 327 test("successful 1", () {});
328 test("successful 2", () {}); 328 test("successful 2", () {});
329 test("successful 3", () {}); 329 test("successful 3", () {});
330 }); 330 });
331 } 331 }
332 332
333 /// An isolate entrypoint that defines a test that fails. 333 /// An isolate entrypoint that defines a test that fails.
334 void _failingTest(SendPort sendPort) { 334 void _failingTest(SendPort sendPort) {
335 IsolateListener.start(sendPort, () => () { 335 IsolateListener.start(sendPort, new Metadata(), () => () {
336 test("failure", () => throw new TestFailure('oh no')); 336 test("failure", () => throw new TestFailure('oh no'));
337 }); 337 });
338 } 338 }
339 339
340 /// An isolate entrypoint that defines a test that fails after succeeding. 340 /// An isolate entrypoint that defines a test that fails after succeeding.
341 void _failAfterSucceedTest(SendPort sendPort) { 341 void _failAfterSucceedTest(SendPort sendPort) {
342 IsolateListener.start(sendPort, () => () { 342 IsolateListener.start(sendPort, new Metadata(), () => () {
343 test("fail after succeed", () { 343 test("fail after succeed", () {
344 pumpEventQueue().then((_) { 344 pumpEventQueue().then((_) {
345 throw new TestFailure('oh no'); 345 throw new TestFailure('oh no');
346 }); 346 });
347 }); 347 });
348 }); 348 });
349 } 349 }
350 350
351 /// An isolate entrypoint that defines a test that fails multiple times. 351 /// An isolate entrypoint that defines a test that fails multiple times.
352 void _multiFailTest(SendPort sendPort) { 352 void _multiFailTest(SendPort sendPort) {
353 IsolateListener.start(sendPort, () => () { 353 IsolateListener.start(sendPort, new Metadata(), () => () {
354 test("multiple failures", () { 354 test("multiple failures", () {
355 Invoker.current.addOutstandingCallback(); 355 Invoker.current.addOutstandingCallback();
356 new Future(() => throw new TestFailure("one")); 356 new Future(() => throw new TestFailure("one"));
357 new Future(() => throw new TestFailure("two")); 357 new Future(() => throw new TestFailure("two"));
358 new Future(() => throw new TestFailure("three")); 358 new Future(() => throw new TestFailure("three"));
359 new Future(() => throw new TestFailure("four")); 359 new Future(() => throw new TestFailure("four"));
360 }); 360 });
361 }); 361 });
362 } 362 }
363 363
364 /// An isolate entrypoint that defines a test that errors. 364 /// An isolate entrypoint that defines a test that errors.
365 void _errorTest(SendPort sendPort) { 365 void _errorTest(SendPort sendPort) {
366 IsolateListener.start(sendPort, () => () { 366 IsolateListener.start(sendPort, new Metadata(), () => () {
367 test("error", () => throw 'oh no'); 367 test("error", () => throw 'oh no');
368 }); 368 });
369 } 369 }
370 370
371 /// An isolate entrypoint that defines a test that errors after succeeding. 371 /// An isolate entrypoint that defines a test that errors after succeeding.
372 void _errorAfterSucceedTest(SendPort sendPort) { 372 void _errorAfterSucceedTest(SendPort sendPort) {
373 IsolateListener.start(sendPort, () => () { 373 IsolateListener.start(sendPort, new Metadata(), () => () {
374 test("error after succeed", () { 374 test("error after succeed", () {
375 pumpEventQueue().then((_) => throw 'oh no'); 375 pumpEventQueue().then((_) => throw 'oh no');
376 }); 376 });
377 }); 377 });
378 } 378 }
379 379
380 /// An isolate entrypoint that defines a test that errors multiple times. 380 /// An isolate entrypoint that defines a test that errors multiple times.
381 void _multiErrorTest(SendPort sendPort) { 381 void _multiErrorTest(SendPort sendPort) {
382 IsolateListener.start(sendPort, () => () { 382 IsolateListener.start(sendPort, new Metadata(), () => () {
383 test("multiple errors", () { 383 test("multiple errors", () {
384 Invoker.current.addOutstandingCallback(); 384 Invoker.current.addOutstandingCallback();
385 new Future(() => throw "one"); 385 new Future(() => throw "one");
386 new Future(() => throw "two"); 386 new Future(() => throw "two");
387 new Future(() => throw "three"); 387 new Future(() => throw "three");
388 new Future(() => throw "four"); 388 new Future(() => throw "four");
389 }); 389 });
390 }); 390 });
391 } 391 }
392 392
393 /// An isolate entrypoint that defines a test that prints twice. 393 /// An isolate entrypoint that defines a test that prints twice.
394 void _printTest(SendPort sendPort) { 394 void _printTest(SendPort sendPort) {
395 IsolateListener.start(sendPort, () => () { 395 IsolateListener.start(sendPort, new Metadata(), () => () {
396 test("prints", () { 396 test("prints", () {
397 print("Hello,"); 397 print("Hello,");
398 return new Future(() => print("world!")); 398 return new Future(() => print("world!"));
399 }); 399 });
400 }); 400 });
401 } 401 }
402 402
OLDNEW
« no previous file with comments | « test/runner/browser/runner_test.dart ('k') | test/runner/parse_metadata_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698