Chromium Code Reviews| Index: test/runner/tag_test.dart |
| diff --git a/test/runner/tag_test.dart b/test/runner/tag_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a4e4f9e9182309f9d6cebf2596797a3bd613430a |
| --- /dev/null |
| +++ b/test/runner/tag_test.dart |
| @@ -0,0 +1,213 @@ |
| +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +@TestOn("vm") |
| + |
| +import 'package:scheduled_test/descriptor.dart' as d; |
| +import 'package:scheduled_test/scheduled_stream.dart'; |
| +import 'package:scheduled_test/scheduled_test.dart'; |
| + |
| +import '../io.dart'; |
| + |
| +void main() { |
| + useSandbox(); |
| + |
| + group("--tags", () { |
| + test("runs only tests containing specified tags", () { |
| + d.file("test.dart", """ |
| +import 'package:test/test.dart'; |
| + |
| +void main() { |
| + test("no tags", () {}); |
| + test("a", () {}, tags: "a"); |
| + test("b", () {}, tags: "b"); |
| + test("bc", () {}, tags: "b,c"); |
| +} |
| +""").create(); |
| + |
| + var test; |
| + |
| + /// [warnings] contains pairs, each containing a comma-separated list of |
| + /// tags the warning is about and the test name. |
| + expectTagWarnings(List<List<String>> warnings) { |
| + for (var warning in warnings) { |
| + test.stderr.expect(consumeThrough(contains( |
| + "WARNING: unrecognized tags {${warning[0]}}" |
| + " in test '${warning[1]}'"))); |
| + } |
| + test.stderr.expect(isDone); |
| + } |
| + |
| + test = runTest(["test.dart"]); |
|
nweiz
2015/11/16 21:59:44
Each of these invocations of the test runner shoul
yjbanov
2015/11/26 06:30:27
Done.
|
| + test.stdout.expect(consumeThrough(contains("+4: All tests passed!"))); |
| + expectTagWarnings([ |
| + ['a', 'a'], |
| + ['b', 'b'], |
| + ['b, c', 'bc'], |
| + ]); |
| + test.shouldExit(0); |
| + |
| + test = runTest(["--tags=a", "test.dart"]); |
| + test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); |
| + expectTagWarnings([ |
| + ['b', 'b'], |
| + ['b, c', 'bc'], |
| + ]); |
| + test.shouldExit(0); |
| + |
| + test = runTest(["--tags=b", "test.dart"]); |
| + test.stdout.expect(consumeThrough(contains("+2: All tests passed!"))); |
| + expectTagWarnings([ |
| + ['a', 'a'], |
| + ['c', 'bc'], |
| + ]); |
| + test.shouldExit(0); |
| + |
| + test = runTest(["--tags=c", "test.dart"]); |
| + test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); |
| + expectTagWarnings([ |
| + ['a', 'a'], |
| + ['b', 'b'], |
| + ['b', 'bc'], |
| + ]); |
| + test.shouldExit(0); |
| + |
| + test = runTest(["--tags=a,b,c", "test.dart"]); |
| + test.stdout.expect(consumeThrough(contains("+3: All tests passed!"))); |
| + expectTagWarnings([]); |
| + test.shouldExit(0); |
| + }); |
| + |
| + test("takes -t abbreviation and --tag typo", () { |
| + d.file("test.dart", """ |
| +import 'package:test/test.dart'; |
| + |
| +void main() { |
| + test("no tags", () {}); |
| + test("a", () {}, tags: "a"); |
| +} |
| +""").create(); |
| + |
| + var test = runTest(["test.dart"]); |
|
nweiz
2015/11/16 21:59:44
You don't need to test what happens if no flags ar
yjbanov
2015/11/26 06:30:27
I was sanity checking the test itself, but done.
|
| + test.stdout.expect(consumeThrough(contains("+2: All tests passed!"))); |
| + test.shouldExit(0); |
| + |
| + test = runTest(["-t", "a", "test.dart"]); |
| + test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); |
| + test.shouldExit(0); |
| + |
| + test = runTest(["--tag=a", "test.dart"]); |
| + test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); |
| + test.shouldExit(0); |
| + }); |
| + }); |
| + |
| + group("--exclude-tags", () { |
| + test("runs only tests containing specified tags", () { |
| + d.file("test.dart", """ |
| +import 'package:test/test.dart'; |
| + |
| +void main() { |
| + test("no tags", () {}); |
| + test("a", () {}, tags: "a"); |
| + test("b", () {}, tags: "b"); |
| + test("bc", () {}, tags: "b,c"); |
| +} |
| +""").create(); |
| + |
| + var test; |
| + |
| + /// [warnings] contains pairs, each containing a comma-separated list of |
| + /// tags the warning is about and the test name. |
| + expectTagWarnings(List<List<String>> warnings) { |
| + for (var warning in warnings) { |
| + test.stderr.expect(consumeThrough(contains( |
| + "WARNING: unrecognized tags {${warning[0]}}" |
| + " in test '${warning[1]}'"))); |
| + } |
| + test.stderr.expect(isDone); |
| + } |
| + |
| + test = runTest(["--exclude-tags=a", "test.dart"]); |
| + test.stdout.expect(consumeThrough(contains("+3: All tests passed!"))); |
| + expectTagWarnings([ |
| + ['b', 'b'], |
| + ['b, c', 'bc'], |
| + ]); |
| + test.shouldExit(0); |
| + |
| + test = runTest(["--exclude-tags=b", "test.dart"]); |
| + test.stdout.expect(consumeThrough(contains("+2: All tests passed!"))); |
| + expectTagWarnings([ |
| + ['a', 'a'], |
| + ['c', 'bc'], |
| + ]); |
| + test.shouldExit(0); |
| + |
| + test = runTest(["--exclude-tags=c", "test.dart"]); |
| + test.stdout.expect(consumeThrough(contains("+3: All tests passed!"))); |
| + expectTagWarnings([ |
| + ['a', 'a'], |
| + ['b', 'b'], |
| + ['b', 'bc'], |
| + ]); |
| + test.shouldExit(0); |
| + |
| + test = runTest(["--exclude-tags=a,b,c", "test.dart"]); |
| + test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); |
| + expectTagWarnings([]); |
| + test.shouldExit(0); |
| + }); |
| + |
| + test("takes -e abbreviation and --exclude-tag typo", () { |
| + d.file("test.dart", """ |
| +import 'package:test/test.dart'; |
| + |
| +void main() { |
| + test("no tags", () {}); |
| + test("a", () {}, tags: "a"); |
| +} |
| +""").create(); |
| + |
| + var test = runTest(["-e", "a", "test.dart"]); |
| + test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); |
| + test.shouldExit(0); |
| + |
| + test = runTest(["--exclude-tag=a", "test.dart"]); |
| + test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); |
| + test.shouldExit(0); |
| + }); |
| + }); |
| + |
| + group('interaction between --tags and --exclude-tags', () { |
| + test('refuses include and exclude the same tag simultaneously', () { |
| + d.file("test.dart", """ |
| +import 'package:test/test.dart'; |
| + |
| +void main() { |
| + test("foo", () {}); |
| +} |
| +""").create(); |
| + |
| + var test = runTest(["-t", "a,b", "-e", "a,b,c", "test.dart"]); |
| + test.stderr.expect(consumeThrough(contains("Included and excluded tag sets may not intersect. Found intersection: a, b"))); |
|
nweiz
2015/11/16 21:59:44
Long line.
yjbanov
2015/11/26 06:30:27
Done.
|
| + test.stderr.expect(consumeThrough(contains("Usage:"))); |
| + test.shouldExit(64); |
| + }); |
| + |
| + test("--exclude-tags takes precedence over --tags", () { |
| + d.file("test.dart", """ |
| +import 'package:test/test.dart'; |
| + |
| +void main() { |
| + test("ab", () {}, tags: "ab"); |
| +} |
| +""").create(); |
| + |
| + var test = runTest(["-t", "a", "-e", "b", "test.dart"]); |
| + test.stdout.expect(consumeThrough(contains("No tests ran"))); |
| + test.shouldExit(0); |
| + }); |
| + }); |
| +} |
|
nweiz
2015/11/16 21:59:44
Also test that you exclude tags specified on the g
yjbanov
2015/11/26 06:30:27
Done.
|