OLD | NEW |
---|---|
(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:convert'; | |
8 | |
9 import 'package:scheduled_test/descriptor.dart' as d; | |
10 import 'package:scheduled_test/scheduled_stream.dart'; | |
kevmoo
2016/02/26 23:06:20
unused import
nweiz
2016/03/01 02:24:04
Done.
| |
11 import 'package:scheduled_test/scheduled_test.dart'; | |
12 | |
13 import 'package:test/src/util/exit_codes.dart' as exit_codes; | |
14 import 'package:test/src/util/io.dart'; | |
15 | |
16 import '../../io.dart'; | |
17 | |
18 void main() { | |
19 useSandbox(); | |
20 | |
21 group("on_platform", () { | |
22 test("applies platform-specific configuration to matching tests", () { | |
23 d.file("dart_test.yaml", JSON.encode({ | |
24 "on_platform": { | |
25 "content-shell": {"timeout": "0s"} | |
26 } | |
27 })).create(); | |
28 | |
29 d.file("test.dart", """ | |
30 import 'dart:async'; | |
31 | |
32 import 'package:test/test.dart'; | |
33 | |
34 void main() { | |
35 test("test", () => new Future.delayed(Duration.ZERO)); | |
36 } | |
37 """).create(); | |
38 | |
39 var test = runTest(["-p", "content-shell,vm", "test.dart"]); | |
40 test.stdout.expect(containsInOrder([ | |
41 "-1: [Dartium Content Shell] test", | |
42 "+1 -1: Some tests failed." | |
43 ])); | |
44 test.shouldExit(1); | |
45 }, tags: ['content-shell']); | |
46 | |
47 test("supports platform selectors", () { | |
48 d.file("dart_test.yaml", JSON.encode({ | |
49 "on_platform": { | |
50 "content-shell || vm": {"timeout": "0s"} | |
51 } | |
52 })).create(); | |
53 | |
54 d.file("test.dart", """ | |
55 import 'dart:async'; | |
56 | |
57 import 'package:test/test.dart'; | |
58 | |
59 void main() { | |
60 test("test", () => new Future.delayed(Duration.ZERO)); | |
61 } | |
62 """).create(); | |
63 | |
64 var test = runTest(["-p", "content-shell,vm", "test.dart"]); | |
65 test.stdout.expect(containsInOrder([ | |
66 "-1: [VM] test", | |
67 "-2: [Dartium Content Shell] test", | |
68 "-2: Some tests failed." | |
69 ])); | |
70 test.shouldExit(1); | |
71 }, tags: ['content-shell']); | |
72 | |
73 group("errors", () { | |
74 test("rejects an invalid selector type", () { | |
75 d.file("dart_test.yaml", '{"on_platform": {12: null}}').create(); | |
76 | |
77 var test = runTest([]); | |
78 test.stderr.expect(containsInOrder([ | |
79 "on_platform key must be a string", | |
80 "^^" | |
81 ])); | |
82 test.shouldExit(exit_codes.data); | |
83 }); | |
84 | |
85 test("rejects an invalid selector", () { | |
86 d.file("dart_test.yaml", JSON.encode({ | |
87 "on_platform": {"foo bar": null} | |
88 })).create(); | |
89 | |
90 var test = runTest([]); | |
91 test.stderr.expect(containsInOrder([ | |
92 "Invalid on_platform key: Expected end of input.", | |
93 "^^^^^^^^^" | |
94 ])); | |
95 test.shouldExit(exit_codes.data); | |
96 }); | |
97 | |
98 test("rejects a selector with an undefined variable", () { | |
99 d.file("dart_test.yaml", JSON.encode({ | |
100 "on_platform": {"foo": null} | |
101 })).create(); | |
102 | |
103 var test = runTest([]); | |
104 test.stderr.expect(containsInOrder([ | |
105 "Invalid on_platform key: Undefined variable.", | |
106 "^^^^^" | |
107 ])); | |
108 test.shouldExit(exit_codes.data); | |
109 }); | |
110 | |
111 test("rejects an invalid map", () { | |
112 d.file("dart_test.yaml", JSON.encode({ | |
113 "on_platform": {"linux": 12} | |
114 })).create(); | |
115 | |
116 var test = runTest([]); | |
117 test.stderr.expect(containsInOrder([ | |
118 "on_platform value must be a map.", | |
119 "^^" | |
120 ])); | |
121 test.shouldExit(exit_codes.data); | |
122 }); | |
123 | |
124 test("rejects an invalid configuration", () { | |
125 d.file("dart_test.yaml", JSON.encode({ | |
126 "on_platform": {"linux": {"timeout": "12p"}} | |
127 })).create(); | |
128 | |
129 var test = runTest([]); | |
130 test.stderr.expect(containsInOrder([ | |
131 "Invalid timeout: expected unit.", | |
132 "^^^^^" | |
133 ])); | |
134 test.shouldExit(exit_codes.data); | |
135 }); | |
136 | |
137 test("rejects runner configuration", () { | |
138 d.file("dart_test.yaml", JSON.encode({ | |
139 "on_platform": {"linux": {"filename": "*_blorp"}} | |
140 })).create(); | |
141 | |
142 var test = runTest([]); | |
143 test.stderr.expect(containsInOrder([ | |
144 "filename isn't supported here.", | |
145 "^^^^^^^^^" | |
146 ])); | |
147 test.shouldExit(exit_codes.data); | |
148 }); | |
149 }); | |
150 }); | |
151 | |
152 group("on_os", () { | |
153 test("applies OS-specific configuration on a matching OS", () { | |
154 d.file("dart_test.yaml", JSON.encode({ | |
155 "on_os": { | |
156 currentOS.identifier: {"filename": "test_*.dart"} | |
157 } | |
158 })).create(); | |
159 | |
160 d.file("foo_test.dart", """ | |
161 import 'package:test/test.dart'; | |
162 | |
163 void main() { | |
164 test("foo_test", () {}); | |
165 } | |
166 """).create(); | |
167 | |
168 d.file("test_foo.dart", """ | |
169 import 'package:test/test.dart'; | |
170 | |
171 void main() { | |
172 test("test_foo", () {}); | |
173 } | |
174 """).create(); | |
175 | |
176 var test = runTest(["."]); | |
177 test.stdout.expect(containsInOrder([ | |
178 "+0: ./test_foo.dart: test_foo", | |
179 "+1: All tests passed!" | |
180 ])); | |
181 test.shouldExit(0); | |
182 }); | |
183 | |
184 test("doesn't OS-specific configuration on a non-matching OS", () { | |
185 d.file("dart_test.yaml", JSON.encode({ | |
186 "on_os": { | |
187 otherOS: {"filename": "test_*.dart"} | |
188 } | |
189 })).create(); | |
190 | |
191 d.file("foo_test.dart", """ | |
192 import 'package:test/test.dart'; | |
193 | |
194 void main() { | |
195 test("foo_test", () {}); | |
196 } | |
197 """).create(); | |
198 | |
199 d.file("test_foo.dart", """ | |
200 import 'package:test/test.dart'; | |
201 | |
202 void main() { | |
203 test("test_foo", () {}); | |
204 } | |
205 """).create(); | |
206 | |
207 var test = runTest(["."]); | |
208 test.stdout.expect(containsInOrder([ | |
209 "+0: ./foo_test.dart: foo_test", | |
210 "+1: All tests passed!" | |
211 ])); | |
212 test.shouldExit(0); | |
213 }); | |
214 | |
215 group("errors", () { | |
216 test("rejects an invalid OS type", () { | |
217 d.file("dart_test.yaml", '{"on_os": {12: null}}').create(); | |
218 | |
219 var test = runTest([]); | |
220 test.stderr.expect(containsInOrder([ | |
221 "on_os key must be a string", | |
222 "^^" | |
223 ])); | |
224 test.shouldExit(exit_codes.data); | |
225 }); | |
226 | |
227 test("rejects an unknown OS name", () { | |
228 d.file("dart_test.yaml", JSON.encode({ | |
229 "on_os": {"foo": null} | |
230 })).create(); | |
231 | |
232 var test = runTest([]); | |
233 test.stderr.expect(containsInOrder([ | |
234 "Invalid on_os key: No such operating system.", | |
235 "^^^^^" | |
236 ])); | |
237 test.shouldExit(exit_codes.data); | |
238 }); | |
239 | |
240 test("rejects an invalid map", () { | |
241 d.file("dart_test.yaml", JSON.encode({ | |
242 "on_os": {"linux": 12} | |
243 })).create(); | |
244 | |
245 var test = runTest([]); | |
246 test.stderr.expect(containsInOrder([ | |
247 "on_os value must be a map.", | |
248 "^^" | |
249 ])); | |
250 test.shouldExit(exit_codes.data); | |
251 }); | |
252 | |
253 test("rejects an invalid configuration", () { | |
254 d.file("dart_test.yaml", JSON.encode({ | |
255 "on_os": {"linux": {"timeout": "12p"}} | |
256 })).create(); | |
257 | |
258 var test = runTest([]); | |
259 test.stderr.expect(containsInOrder([ | |
260 "Invalid timeout: expected unit.", | |
261 "^^^^^" | |
262 ])); | |
263 test.shouldExit(exit_codes.data); | |
264 }); | |
265 }); | |
266 }); | |
267 } | |
OLD | NEW |