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

Side by Side Diff: test/runner/browser/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/backend/metadata_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:io'; 7 import 'dart:io';
8 8
9 import 'package:path/path.dart' as p; 9 import 'package:path/path.dart' as p;
10 import 'package:test/src/util/io.dart'; 10 import 'package:test/src/util/io.dart';
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 void main() { 507 void main() {
508 test("timeout", () {}); 508 test("timeout", () {});
509 } 509 }
510 '''); 510 ''');
511 511
512 var result = _runUnittest(["-p", "chrome", "test.dart"]); 512 var result = _runUnittest(["-p", "chrome", "test.dart"]);
513 expect(result.stdout, contains("Test timed out after 0 seconds.")); 513 expect(result.stdout, contains("Test timed out after 0 seconds."));
514 expect(result.stdout, contains("-1: Some tests failed.")); 514 expect(result.stdout, contains("-1: Some tests failed."));
515 }); 515 });
516 516
517 group("in onPlatform", () { 517 group("with onPlatform", () {
518 test("respects matching Skips", () { 518 test("respects matching Skips", () {
519 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(''' 519 new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
520 import 'dart:async'; 520 import 'dart:async';
521 521
522 import 'package:test/test.dart'; 522 import 'package:test/test.dart';
523 523
524 void main() { 524 void main() {
525 test("fail", () => throw 'oh no', onPlatform: {"chrome": new Skip()}); 525 test("fail", () => throw 'oh no', onPlatform: {"chrome": new Skip()});
526 } 526 }
527 '''); 527 ''');
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 var result = _runUnittest(["-p", "chrome", "test.dart"]); 600 var result = _runUnittest(["-p", "chrome", "test.dart"]);
601 expect(result.stdout, contains("Skip: fifth")); 601 expect(result.stdout, contains("Skip: fifth"));
602 expect(result.stdout, isNot(anyOf([ 602 expect(result.stdout, isNot(anyOf([
603 contains("Skip: first"), 603 contains("Skip: first"),
604 contains("Skip: second"), 604 contains("Skip: second"),
605 contains("Skip: third"), 605 contains("Skip: third"),
606 contains("Skip: fourth") 606 contains("Skip: fourth")
607 ]))); 607 ])));
608 }); 608 });
609 }); 609 });
610
611 group("with an @OnPlatform annotation", () {
612 test("respects matching Skips", () {
613 new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
614 @OnPlatform(const {"chrome": const Skip()})
615
616 import 'dart:async';
617
618 import 'package:test/test.dart';
619
620 void main() {
621 test("fail", () => throw 'oh no');
622 }
623 ''');
624
625 var result = _runUnittest(["-p", "chrome", "test.dart"]);
626 expect(result.stdout, contains("+0 ~1: All tests skipped."));
627 });
628
629 test("ignores non-matching Skips", () {
630 new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
631 @OnPlatform(const {"vm": const Skip()})
632
633 import 'dart:async';
634
635 import 'package:test/test.dart';
636
637 void main() {
638 test("success", () {});
639 }
640 ''');
641
642 var result = _runUnittest(["-p", "chrome", "test.dart"]);
643 expect(result.stdout, contains("+1: All tests passed!"));
644 });
645
646 test("respects matching Timeouts", () {
647 new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
648 @OnPlatform(const {
649 "chrome": const Timeout(const Duration(seconds: 0))
650 })
651
652 import 'dart:async';
653
654 import 'package:test/test.dart';
655
656 void main() {
657 test("fail", () => throw 'oh no');
658 }
659 ''');
660
661 var result = _runUnittest(["-p", "chrome", "test.dart"]);
662 expect(result.stdout, contains("Test timed out after 0 seconds."));
663 expect(result.stdout, contains("-1: Some tests failed."));
664 });
665
666 test("ignores non-matching Timeouts", () {
667 new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
668 @OnPlatform(const {
669 "vm": const Timeout(const Duration(seconds: 0))
670 })
671
672 import 'dart:async';
673
674 import 'package:test/test.dart';
675
676 void main() {
677 test("success", () {});
678 }
679 ''');
680
681 var result = _runUnittest(["-p", "chrome", "test.dart"]);
682 expect(result.stdout, contains("+1: All tests passed!"));
683 });
684 });
610 } 685 }
611 686
612 ProcessResult _runUnittest(List<String> args) => 687 ProcessResult _runUnittest(List<String> args) =>
613 runUnittest(args, workingDirectory: _sandbox); 688 runUnittest(args, workingDirectory: _sandbox);
OLDNEW
« no previous file with comments | « test/backend/metadata_test.dart ('k') | test/runner/parse_metadata_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698