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

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

Issue 1405633004: feature: tag tests; choose tags on command line Base URL: git@github.com:yjbanov/test.git@tags
Patch Set: address review comments Created 5 years, 1 month 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
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 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 test("produces an error when no tests match", () { 665 test("produces an error when no tests match", () {
666 d.file("test.dart", _success).create(); 666 d.file("test.dart", _success).create();
667 667
668 var test = runTest(["--plain-name", "no match", "test.dart"]); 668 var test = runTest(["--plain-name", "no match", "test.dart"]);
669 test.stderr.expect( 669 test.stderr.expect(
670 consumeThrough(contains('No tests match "no match".'))); 670 consumeThrough(contains('No tests match "no match".')));
671 test.shouldExit(exit_codes.data); 671 test.shouldExit(exit_codes.data);
672 }); 672 });
673 }); 673 });
674 }); 674 });
675
676 group("tags", () {
nweiz 2015/11/03 00:43:16 I'm trying to keep runner_test.dart from getting m
yjbanov 2015/11/11 06:40:20 Done.
677 test("runs only tests containing specified tags", () {
678 d.file("test.dart", """
679 import 'package:test/test.dart';
680
681 void main() {
682 test("no tags", () {});
683 test("a", () {}, tags: "a");
684 test("b", () {}, tags: "b");
685 test("bc", () {}, tags: "b,c");
675 } 686 }
687 """).create();
688
689 var test;
690
691 /// [warnings] contains pairs, each containing a comma-separated list of
692 /// tags the warning is about and the test name.
693 expectTagWarnings(List<List<String>> warnings) {
694 for (var warning in warnings) {
695 test.stderr.expect(consumeThrough(contains(
696 "WARNING: unrecognized tags {${warning[0]}}"
697 " in test '${warning[1]}'")));
698 }
699 test.stderr.expect(isDone);
700 }
701
702 test = runTest(["test.dart"]);
703 test.stdout.expect(consumeThrough(contains("+4: All tests passed!")));
704 expectTagWarnings([
705 ['a', 'a'],
706 ['b', 'b'],
707 ['b, c', 'bc'],
708 ]);
709 test.shouldExit(0);
710
711 test = runTest(["--tags=a", "test.dart"]);
712 test.stdout.expect(consumeThrough(contains("+1: All tests passed!")));
713 expectTagWarnings([
714 ['b', 'b'],
715 ['b, c', 'bc'],
716 ]);
717 test.shouldExit(0);
718
719 test = runTest(["--tags=b", "test.dart"]);
720 test.stdout.expect(consumeThrough(contains("+2: All tests passed!")));
721 expectTagWarnings([
722 ['a', 'a'],
723 ['c', 'bc'],
724 ]);
725 test.shouldExit(0);
726
727 test = runTest(["--tags=c", "test.dart"]);
728 test.stdout.expect(consumeThrough(contains("+1: All tests passed!")));
729 expectTagWarnings([
730 ['a', 'a'],
731 ['b', 'b'],
732 ['b', 'bc'],
733 ]);
734 test.shouldExit(0);
735
736 test = runTest(["--tags=a,b,c", "test.dart"]);
737 test.stdout.expect(consumeThrough(contains("+3: All tests passed!")));
738 expectTagWarnings([]);
739 test.shouldExit(0);
740 });
741
742 test("takes -t abbreviation and --tag typo", () {
743 d.file("test.dart", """
744 import 'package:test/test.dart';
745
746 void main() {
747 test("no tags", () {});
748 test("a", () {}, tags: "a");
749 }
750 """).create();
751
752 var test = runTest(["test.dart"]);
753 test.stdout.expect(consumeThrough(contains("+2: All tests passed!")));
754 test.shouldExit(0);
755
756 test = runTest(["-t", "a", "test.dart"]);
757 test.stdout.expect(consumeThrough(contains("+1: All tests passed!")));
758 test.shouldExit(0);
759
760 test = runTest(["--tag=a", "test.dart"]);
761 test.stdout.expect(consumeThrough(contains("+1: All tests passed!")));
762 test.shouldExit(0);
763 });
764 });
765 }
OLDNEW
« lib/src/backend/metadata.dart ('K') | « test/backend/metadata_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698