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

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

Issue 1097183003: Add an "onPlatform" parameter to test() and group(). (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/runner_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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 506
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
517 group("in onPlatform", () {
518 test("respects matching Skips", () {
519 new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
520 import 'dart:async';
521
522 import 'package:test/test.dart';
523
524 void main() {
525 test("fail", () => throw 'oh no', onPlatform: {"chrome": new Skip()});
526 }
527 ''');
528
529 var result = _runUnittest(["-p", "chrome", "test.dart"]);
530 expect(result.stdout, contains("+0 ~1: All tests skipped."));
531 });
532
533 test("ignores non-matching Skips", () {
534 new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
535 import 'dart:async';
536
537 import 'package:test/test.dart';
538
539 void main() {
540 test("success", () {}, onPlatform: {"vm": new Skip()});
541 }
542 ''');
543
544 var result = _runUnittest(["-p", "chrome", "test.dart"]);
545 expect(result.stdout, contains("+1: All tests passed!"));
546 });
547
548 test("respects matching Timeouts", () {
549 new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
550 import 'dart:async';
551
552 import 'package:test/test.dart';
553
554 void main() {
555 test("fail", () => throw 'oh no', onPlatform: {
556 "chrome": new Timeout(new Duration(seconds: 0))
557 });
558 }
559 ''');
560
561 var result = _runUnittest(["-p", "chrome", "test.dart"]);
562 expect(result.stdout, contains("Test timed out after 0 seconds."));
563 expect(result.stdout, contains("-1: Some tests failed."));
564 });
565
566 test("ignores non-matching Timeouts", () {
567 new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
568 import 'dart:async';
569
570 import 'package:test/test.dart';
571
572 void main() {
573 test("success", () {}, onPlatform: {
574 "vm": new Timeout(new Duration(seconds: 0))
575 });
576 }
577 ''');
578
579 var result = _runUnittest(["-p", "chrome", "test.dart"]);
580 expect(result.stdout, contains("+1: All tests passed!"));
581 });
582
583 test("applies matching platforms in order", () {
584 new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
585 import 'dart:async';
586
587 import 'package:test/test.dart';
588
589 void main() {
590 test("success", () {}, onPlatform: {
591 "chrome": new Skip("first"),
592 "chrome || windows": new Skip("second"),
593 "chrome || linux": new Skip("third"),
594 "chrome || mac-os": new Skip("fourth"),
595 "chrome || android": new Skip("fifth")
596 });
597 }
598 ''');
599
600 var result = _runUnittest(["-p", "chrome", "test.dart"]);
601 expect(result.stdout, contains("Skip: fifth"));
602 expect(result.stdout, isNot(anyOf([
603 contains("Skip: first"),
604 contains("Skip: second"),
605 contains("Skip: third"),
606 contains("Skip: fourth")
607 ])));
608 });
609 });
516 } 610 }
517 611
518 ProcessResult _runUnittest(List<String> args) => 612 ProcessResult _runUnittest(List<String> args) =>
519 runUnittest(args, workingDirectory: _sandbox); 613 runUnittest(args, workingDirectory: _sandbox);
OLDNEW
« no previous file with comments | « test/backend/metadata_test.dart ('k') | test/runner/runner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698