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

Side by Side Diff: test/runner/name_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/configuration/top_level_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
(Empty)
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
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.
4
5 @TestOn("vm")
6
7 import 'dart:io';
8 import 'dart:math' as math;
9
10 import 'package:scheduled_test/descriptor.dart' as d;
11 import 'package:scheduled_test/scheduled_stream.dart';
12 import 'package:scheduled_test/scheduled_test.dart';
13 import 'package:test/src/util/exit_codes.dart' as exit_codes;
14
15 import '../io.dart';
16
17 void main() {
18 useSandbox();
19
20 group("with the --name flag,", () {
21 test("selects tests with matching names", () {
22 d.file("test.dart", """
23 import 'package:test/test.dart';
24
25 void main() {
26 test("selected 1", () {});
27 test("nope", () => throw new TestFailure("oh no"));
28 test("selected 2", () {});
29 }
30 """).create();
31
32 var test = runTest(["--name", "selected", "test.dart"]);
33 test.stdout.expect(consumeThrough(contains("+2: All tests passed!")));
34 test.shouldExit(0);
35 });
36
37 test("supports RegExp syntax", () {
38 d.file("test.dart", """
39 import 'package:test/test.dart';
40
41 void main() {
42 test("test 1", () {});
43 test("test 2", () => throw new TestFailure("oh no"));
44 test("test 3", () {});
45 }
46 """).create();
47
48 var test = runTest(["--name", "test [13]", "test.dart"]);
49 test.stdout.expect(consumeThrough(contains("+2: All tests passed!")));
50 test.shouldExit(0);
51 });
52
53 test("selects more narrowly when passed multiple times", () {
54 d.file("test.dart", """
55 import 'package:test/test.dart';
56
57 void main() {
58 test("selected 1", () {});
59 test("nope", () => throw new TestFailure("oh no"));
60 test("selected 2", () {});
61 }
62 """).create();
63
64 var test = runTest(["--name", "selected", "--name", "1", "test.dart"]);
65 test.stdout.expect(consumeThrough(contains("+1: All tests passed!")));
66 test.shouldExit(0);
67 });
68
69 test("produces an error when no tests match", () {
70 d.file("test.dart", """
71 import 'package:test/test.dart';
72
73 void main() {
74 test("test", () {});
75 }
76 """).create();
77
78 var test = runTest(["--name", "no match", "test.dart"]);
79 test.stderr.expect(consumeThrough(
80 contains('No tests match regular expression "no match".')));
81 test.shouldExit(exit_codes.data);
82 });
83
84 test("doesn't filter out load exceptions", () {
85 var test = runTest(["--name", "name", "file"]);
86 test.stdout.expect(containsInOrder([
87 '-1: loading file',
88 ' Failed to load "file": Does not exist.'
89 ]));
90 test.shouldExit(1);
91 });
92 });
93
94 group("with the --plain-name flag,", () {
95 test("selects tests with matching names", () {
96 d.file("test.dart", """
97 import 'package:test/test.dart';
98
99 void main() {
100 test("selected 1", () {});
101 test("nope", () => throw new TestFailure("oh no"));
102 test("selected 2", () {});
103 }
104 """).create();
105
106 var test = runTest(["--plain-name", "selected", "test.dart"]);
107 test.stdout.expect(consumeThrough(contains("+2: All tests passed!")));
108 test.shouldExit(0);
109 });
110
111 test("doesn't support RegExp syntax", () {
112 d.file("test.dart", """
113 import 'package:test/test.dart';
114
115 void main() {
116 test("test 1", () => throw new TestFailure("oh no"));
117 test("test 2", () => throw new TestFailure("oh no"));
118 test("test [12]", () {});
119 }
120 """).create();
121
122 var test = runTest(["--plain-name", "test [12]", "test.dart"]);
123 test.stdout.expect(consumeThrough(contains("+1: All tests passed!")));
124 test.shouldExit(0);
125 });
126
127 test("selects more narrowly when passed multiple times", () {
128 d.file("test.dart", """
129 import 'package:test/test.dart';
130
131 void main() {
132 test("selected 1", () {});
133 test("nope", () => throw new TestFailure("oh no"));
134 test("selected 2", () {});
135 }
136 """).create();
137
138 var test = runTest(
139 ["--plain-name", "selected", "--plain-name", "1", "test.dart"]);
140 test.stdout.expect(consumeThrough(contains("+1: All tests passed!")));
141 test.shouldExit(0);
142 });
143
144 test("produces an error when no tests match", () {
145 d.file("test.dart", """
146 import 'package:test/test.dart';
147
148 void main() {
149 test("test", () {});
150 }
151 """).create();
152
153 var test = runTest(["--plain-name", "no match", "test.dart"]);
154 test.stderr.expect(
155 consumeThrough(contains('No tests match "no match".')));
156 test.shouldExit(exit_codes.data);
157 });
158 });
159
160 test("--name and --plain-name together narrow the selection", () {
161 d.file("test.dart", """
162 import 'package:test/test.dart';
163
164 void main() {
165 test("selected 1", () {});
166 test("nope", () => throw new TestFailure("oh no"));
167 test("selected 2", () {});
168 }
169 """).create();
170
171 var test = runTest(
172 ["--name", ".....", "--plain-name", "e", "test.dart"]);
173 test.stdout.expect(consumeThrough(contains("+2: All tests passed!")));
174 test.shouldExit(0);
175 });
176 }
OLDNEW
« no previous file with comments | « test/runner/configuration/top_level_test.dart ('k') | test/runner/runner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698