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

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

Issue 1802133002: Add names and plain_names fields. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 4 years, 9 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/name_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:scheduled_test/descriptor.dart' as d; 10 import 'package:scheduled_test/descriptor.dart' as d;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 final _usage = """ 44 final _usage = """
45 Usage: pub run test:test [files or directories...] 45 Usage: pub run test:test [files or directories...]
46 46
47 -h, --help Shows this usage information. 47 -h, --help Shows this usage information.
48 --version Shows the package's version. 48 --version Shows the package's version.
49 49
50 ======== Selecting Tests 50 ======== Selecting Tests
51 -n, --name A substring of the name of the test to run. 51 -n, --name A substring of the name of the test to run.
52 Regular expression syntax is supported. 52 Regular expression syntax is supported.
53 If passed multiple times, tests must match all su bstrings.
53 54
54 -N, --plain-name A plain-text substring of the name of the test to run. 55 -N, --plain-name A plain-text substring of the name of the test to run.
56 If passed multiple times, tests must match all su bstrings.
57
55 -t, --tags Run only tests with all of the specified tags. 58 -t, --tags Run only tests with all of the specified tags.
56 Supports boolean selector syntax. 59 Supports boolean selector syntax.
57 60
58 -x, --exclude-tags Don't run tests with any of the specified tags. 61 -x, --exclude-tags Don't run tests with any of the specified tags.
59 Supports boolean selector syntax. 62 Supports boolean selector syntax.
60 63
61 ======== Running Tests 64 ======== Running Tests
62 -p, --platform The platform(s) on which to run the tests. 65 -p, --platform The platform(s) on which to run the tests.
63 $_browsers 66 $_browsers
64 67
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 test("success", () {}); 556 test("success", () {});
554 } 557 }
555 ''').create(); 558 ''').create();
556 559
557 var test = runTest(["test.dart"]); 560 var test = runTest(["test.dart"]);
558 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); 561 test.stdout.expect(consumeThrough(contains("+1: All tests passed!")));
559 test.shouldExit(0); 562 test.shouldExit(0);
560 }); 563 });
561 }); 564 });
562 565
563 group("flags:", () { 566 test("with the --color flag, uses colors", () {
564 test("with the --color flag, uses colors", () { 567 d.file("test.dart", _failure).create();
565 d.file("test.dart", _failure).create(); 568 var test = runTest(["--color", "test.dart"]);
566 var test = runTest(["--color", "test.dart"]); 569 // This is the color code for red.
567 // This is the color code for red. 570 test.stdout.expect(consumeThrough(contains("\u001b[31m")));
568 test.stdout.expect(consumeThrough(contains("\u001b[31m"))); 571 test.shouldExit();
569 test.shouldExit();
570 });
571
572 group("with the --name flag,", () {
573 test("selects tests with matching names", () {
574 d.file("test.dart", """
575 import 'dart:async';
576
577 import 'package:test/test.dart';
578
579 void main() {
580 test("selected 1", () {});
581 test("nope", () => throw new TestFailure("oh no"));
582 test("selected 2", () {});
583 }
584 """).create();
585
586 var test = runTest(["--name", "selected", "test.dart"]);
587 test.stdout.expect(consumeThrough(contains("+2: All tests passed!")));
588 test.shouldExit(0);
589 });
590
591 test("supports RegExp syntax", () {
592 d.file("test.dart", """
593 import 'dart:async';
594
595 import 'package:test/test.dart';
596
597 void main() {
598 test("test 1", () {});
599 test("test 2", () => throw new TestFailure("oh no"));
600 test("test 3", () {});
601 }
602 """).create();
603
604 var test = runTest(["--name", "test [13]", "test.dart"]);
605 test.stdout.expect(consumeThrough(contains("+2: All tests passed!")));
606 test.shouldExit(0);
607 });
608
609 test("produces an error when no tests match", () {
610 d.file("test.dart", _success).create();
611
612 var test = runTest(["--name", "no match", "test.dart"]);
613 test.stderr.expect(consumeThrough(
614 contains('No tests match regular expression "no match".')));
615 test.shouldExit(exit_codes.data);
616 });
617
618 test("doesn't filter out load exceptions", () {
619 var test = runTest(["--name", "name", "file"]);
620 test.stdout.expect(containsInOrder([
621 '-1: loading file',
622 ' Failed to load "file": Does not exist.'
623 ]));
624 test.shouldExit(1);
625 });
626 });
627
628 group("with the --plain-name flag,", () {
629 test("selects tests with matching names", () {
630 d.file("test.dart", """
631 import 'dart:async';
632
633 import 'package:test/test.dart';
634
635 void main() {
636 test("selected 1", () {});
637 test("nope", () => throw new TestFailure("oh no"));
638 test("selected 2", () {});
639 }
640 """).create();
641
642 var test = runTest(["--plain-name", "selected", "test.dart"]);
643 test.stdout.expect(consumeThrough(contains("+2: All tests passed!")));
644 test.shouldExit(0);
645 });
646
647 test("doesn't support RegExp syntax", () {
648 d.file("test.dart", """
649 import 'dart:async';
650
651 import 'package:test/test.dart';
652
653 void main() {
654 test("test 1", () => throw new TestFailure("oh no"));
655 test("test 2", () => throw new TestFailure("oh no"));
656 test("test [12]", () {});
657 }
658 """).create();
659
660 var test = runTest(["--plain-name", "test [12]", "test.dart"]);
661 test.stdout.expect(consumeThrough(contains("+1: All tests passed!")));
662 test.shouldExit(0);
663 });
664
665 test("produces an error when no tests match", () {
666 d.file("test.dart", _success).create();
667
668 var test = runTest(["--plain-name", "no match", "test.dart"]);
669 test.stderr.expect(
670 consumeThrough(contains('No tests match "no match".')));
671 test.shouldExit(exit_codes.data);
672 });
673 });
674 }); 572 });
675 } 573 }
OLDNEW
« no previous file with comments | « test/runner/name_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698