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

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

Issue 1092153003: Support an @OnPlatform annotation. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes 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/parse_metadata_test.dart ('k') | no next file » | 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:io'; 7 import 'dart:io';
8 import 'dart:math' as math; 8 import 'dart:math' as math;
9 9
10 import 'package:path/path.dart' as p; 10 import 'package:path/path.dart' as p;
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 370
371 void main() { 371 void main() {
372 test("fail", () => throw 'oh no'); 372 test("fail", () => throw 'oh no');
373 } 373 }
374 '''); 374 ''');
375 375
376 var result = _runUnittest(["test.dart"]); 376 var result = _runUnittest(["test.dart"]);
377 expect(result.stdout, contains("+0 ~1: All tests skipped.")); 377 expect(result.stdout, contains("+0 ~1: All tests skipped."));
378 }); 378 });
379 379
380 group("in onPlatform", () { 380 group("with onPlatform", () {
381 test("respects matching Skips", () { 381 test("respects matching Skips", () {
382 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(''' 382 new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
383 import 'dart:async'; 383 import 'dart:async';
384 384
385 import 'package:test/test.dart'; 385 import 'package:test/test.dart';
386 386
387 void main() { 387 void main() {
388 test("fail", () => throw 'oh no', onPlatform: {"vm": new Skip()}); 388 test("fail", () => throw 'oh no', onPlatform: {"vm": new Skip()});
389 } 389 }
390 '''); 390 ''');
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 expect(result.stdout, contains("Skip: fifth")); 464 expect(result.stdout, contains("Skip: fifth"));
465 expect(result.stdout, isNot(anyOf([ 465 expect(result.stdout, isNot(anyOf([
466 contains("Skip: first"), 466 contains("Skip: first"),
467 contains("Skip: second"), 467 contains("Skip: second"),
468 contains("Skip: third"), 468 contains("Skip: third"),
469 contains("Skip: fourth") 469 contains("Skip: fourth")
470 ]))); 470 ])));
471 }); 471 });
472 }); 472 });
473 473
474 group("with an @OnPlatform annotation", () {
475 test("respects matching Skips", () {
476 new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
477 @OnPlatform(const {"vm": const Skip()})
478
479 import 'dart:async';
480
481 import 'package:test/test.dart';
482
483 void main() {
484 test("fail", () => throw 'oh no');
485 }
486 ''');
487
488 var result = _runUnittest(["test.dart"]);
489 expect(result.stdout, contains("+0 ~1: All tests skipped."));
490 });
491
492 test("ignores non-matching Skips", () {
493 new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
494 @OnPlatform(const {"chrome": const Skip()})
495
496 import 'dart:async';
497
498 import 'package:test/test.dart';
499
500 void main() {
501 test("success", () {});
502 }
503 ''');
504
505 var result = _runUnittest(["test.dart"]);
506 expect(result.stdout, contains("+1: All tests passed!"));
507 });
508
509 test("respects matching Timeouts", () {
510 new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
511 @OnPlatform(const {
512 "vm": const Timeout(const Duration(seconds: 0))
513 })
514
515 import 'dart:async';
516
517 import 'package:test/test.dart';
518
519 void main() {
520 test("fail", () => throw 'oh no');
521 }
522 ''');
523
524 var result = _runUnittest(["test.dart"]);
525 expect(result.stdout, contains("Test timed out after 0 seconds."));
526 expect(result.stdout, contains("-1: Some tests failed."));
527 });
528
529 test("ignores non-matching Timeouts", () {
530 new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
531 @OnPlatform(const {
532 "chrome": const Timeout(const Duration(seconds: 0))
533 })
534
535 import 'dart:async';
536
537 import 'package:test/test.dart';
538
539 void main() {
540 test("success", () {});
541 }
542 ''');
543
544 var result = _runUnittest(["test.dart"]);
545 expect(result.stdout, contains("+1: All tests passed!"));
546 });
547 });
548
474 group("flags:", () { 549 group("flags:", () {
475 test("with the --color flag, uses colors", () { 550 test("with the --color flag, uses colors", () {
476 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(_failure); 551 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(_failure);
477 var result = _runUnittest(["--color", "test.dart"]); 552 var result = _runUnittest(["--color", "test.dart"]);
478 // This is the color code for red. 553 // This is the color code for red.
479 expect(result.stdout, contains("\u001b[31m")); 554 expect(result.stdout, contains("\u001b[31m"));
480 }); 555 });
481 556
482 group("with the --name flag,", () { 557 group("with the --name flag,", () {
483 test("selects tests with matching names", () { 558 test("selects tests with matching names", () {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 }); 657 });
583 }); 658 });
584 }); 659 });
585 } 660 }
586 661
587 ProcessResult _runUnittest(List<String> args) => 662 ProcessResult _runUnittest(List<String> args) =>
588 runUnittest(args, workingDirectory: _sandbox); 663 runUnittest(args, workingDirectory: _sandbox);
589 664
590 ProcessResult _runDart(List<String> args) => 665 ProcessResult _runDart(List<String> args) =>
591 runDart(args, workingDirectory: _sandbox); 666 runDart(args, workingDirectory: _sandbox);
OLDNEW
« no previous file with comments | « test/runner/parse_metadata_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698