OLD | NEW |
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 'package:scheduled_test/descriptor.dart' as d; | 7 import 'package:scheduled_test/descriptor.dart' as d; |
8 import 'package:scheduled_test/scheduled_stream.dart'; | 8 import 'package:scheduled_test/scheduled_stream.dart'; |
9 import 'package:scheduled_test/scheduled_test.dart'; | 9 import 'package:scheduled_test/scheduled_test.dart'; |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 }); | 53 }); |
54 | 54 |
55 test("with multiple tags, runs only tests matching all of them", () { | 55 test("with multiple tags, runs only tests matching all of them", () { |
56 var test = runTest(["--tags=b,c", "test.dart"]); | 56 var test = runTest(["--tags=b,c", "test.dart"]); |
57 test.stdout.expect(tagWarnings(['a'])); | 57 test.stdout.expect(tagWarnings(['a'])); |
58 test.stdout.expect(consumeThrough(contains(": bc"))); | 58 test.stdout.expect(consumeThrough(contains(": bc"))); |
59 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); | 59 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); |
60 test.shouldExit(0); | 60 test.shouldExit(0); |
61 }); | 61 }); |
62 | 62 |
| 63 test("supports boolean selector syntax", () { |
| 64 var test = runTest(["--tags=b || c", "test.dart"]); |
| 65 test.stdout.expect(tagWarnings(['a'])); |
| 66 test.stdout.expect(consumeThrough(contains(": b"))); |
| 67 test.stdout.expect(consumeThrough(contains(": bc"))); |
| 68 test.stdout.expect(consumeThrough(contains("+2: All tests passed!"))); |
| 69 test.shouldExit(0); |
| 70 }); |
| 71 |
63 test("prints no warnings when all tags are specified", () { | 72 test("prints no warnings when all tags are specified", () { |
64 var test = runTest(["--tags=a,b,c", "test.dart"]); | 73 var test = runTest(["--tags=a,b,c", "test.dart"]); |
65 test.stdout.expect(consumeThrough(contains("No tests ran."))); | 74 test.stdout.expect(consumeThrough(contains("No tests ran."))); |
66 test.shouldExit(0); | 75 test.shouldExit(0); |
67 }); | 76 }); |
68 }); | 77 }); |
69 | 78 |
70 group("--exclude-tags", () { | 79 group("--exclude-tags", () { |
71 test("dosn't run a test with only an excluded tag", () { | 80 test("dosn't run a test with only an excluded tag", () { |
72 var test = runTest(["--exclude-tags=a", "test.dart"]); | 81 var test = runTest(["--exclude-tags=a", "test.dart"]); |
(...skipping 17 matching lines...) Expand all Loading... |
90 | 99 |
91 test("allows unused tags", () { | 100 test("allows unused tags", () { |
92 var test = runTest(["--exclude-tags=b,z", "test.dart"]); | 101 var test = runTest(["--exclude-tags=b,z", "test.dart"]); |
93 test.stdout.expect(tagWarnings(['a', 'c'])); | 102 test.stdout.expect(tagWarnings(['a', 'c'])); |
94 test.stdout.expect(consumeThrough(contains(": no tags"))); | 103 test.stdout.expect(consumeThrough(contains(": no tags"))); |
95 test.stdout.expect(consumeThrough(contains(": a"))); | 104 test.stdout.expect(consumeThrough(contains(": a"))); |
96 test.stdout.expect(consumeThrough(contains("+2: All tests passed!"))); | 105 test.stdout.expect(consumeThrough(contains("+2: All tests passed!"))); |
97 test.shouldExit(0); | 106 test.shouldExit(0); |
98 }); | 107 }); |
99 | 108 |
| 109 test("supports boolean selector syntax", () { |
| 110 var test = runTest(["--exclude-tags=b && c", "test.dart"]); |
| 111 test.stdout.expect(tagWarnings(['a'])); |
| 112 test.stdout.expect(consumeThrough(contains(": no tags"))); |
| 113 test.stdout.expect(consumeThrough(contains(": a"))); |
| 114 test.stdout.expect(consumeThrough(contains(": b"))); |
| 115 test.stdout.expect(consumeThrough(contains("+3: All tests passed!"))); |
| 116 test.shouldExit(0); |
| 117 }); |
| 118 |
100 test("prints no warnings when all tags are specified", () { | 119 test("prints no warnings when all tags are specified", () { |
101 var test = runTest(["--exclude-tags=a,b,c", "test.dart"]); | 120 var test = runTest(["--exclude-tags=a,b,c", "test.dart"]); |
102 test.stdout.expect(consumeThrough(contains(": no tags"))); | 121 test.stdout.expect(consumeThrough(contains(": no tags"))); |
103 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); | 122 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); |
104 test.shouldExit(0); | 123 test.shouldExit(0); |
105 }); | 124 }); |
106 }); | 125 }); |
107 | 126 |
108 group("with a tagged group", () { | 127 group("with a tagged group", () { |
109 setUp(() { | 128 setUp(() { |
(...skipping 18 matching lines...) Expand all Loading... |
128 }); | 147 }); |
129 | 148 |
130 test("excludes tags specified on the group", () { | 149 test("excludes tags specified on the group", () { |
131 var test = runTest(["-t", "a", "test.dart"]); | 150 var test = runTest(["-t", "a", "test.dart"]); |
132 test.stdout.expect(consumeThrough(contains(": a in"))); | 151 test.stdout.expect(consumeThrough(contains(": a in"))); |
133 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); | 152 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); |
134 test.shouldExit(0); | 153 test.shouldExit(0); |
135 }); | 154 }); |
136 }); | 155 }); |
137 | 156 |
138 group('with --tags and --exclude-tags', () { | |
139 test('refuses to include and exclude the same tag simultaneously', () { | |
140 var test = runTest(["-t", "a,b", "-x", "a,b,c", "test.dart"]); | |
141 test.stderr.expect(consumeThrough( | |
142 contains("The tags a and b were both included and excluded."))); | |
143 test.shouldExit(64); | |
144 }); | |
145 | |
146 test("--exclude-tags takes precedence over --tags", () { | |
147 var test = runTest(["-t", "b", "-x", "c", "test.dart"]); | |
148 test.stdout.expect(consumeThrough(contains(": b"))); | |
149 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); | |
150 test.shouldExit(0); | |
151 }); | |
152 }); | |
153 | |
154 test('respects top-level @Tags annotations', () { | 157 test('respects top-level @Tags annotations', () { |
155 d.file("test.dart", """ | 158 d.file("test.dart", """ |
156 @Tags(const ['a']) | 159 @Tags(const ['a']) |
157 import 'package:test/test.dart'; | 160 import 'package:test/test.dart'; |
158 | 161 |
159 void main() { | 162 void main() { |
160 test("foo", () {}); | 163 test("foo", () {}); |
161 } | 164 } |
162 """).create(); | 165 """).create(); |
163 | 166 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 } | 331 } |
329 | 332 |
330 // Consume until the end of the warning block, and assert that it has no | 333 // Consume until the end of the warning block, and assert that it has no |
331 // further tags than the ones we specified. | 334 // further tags than the ones we specified. |
332 yield consumeWhile(isNot(anyOf([contains(" was used in"), isEmpty]))); | 335 yield consumeWhile(isNot(anyOf([contains(" was used in"), isEmpty]))); |
333 yield isEmpty; | 336 yield isEmpty; |
334 }()); | 337 }()); |
335 | 338 |
336 /// Returns a [StreamMatcher] that matches the lines of [string] in order. | 339 /// Returns a [StreamMatcher] that matches the lines of [string] in order. |
337 StreamMatcher lines(String string) => inOrder(string.split("\n")); | 340 StreamMatcher lines(String string) => inOrder(string.split("\n")); |
OLD | NEW |