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

Side by Side Diff: test/runner/configuration/top_level_test.dart

Issue 1649663003: Add basic support for a configuration file. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 4 years, 10 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
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';
kevmoo 2016/02/03 23:01:56 dart:io is unused
8 import 'dart:convert';
9
10 import 'package:path/path.dart' as p;
11 import 'package:scheduled_test/descriptor.dart' as d;
12 import 'package:scheduled_test/scheduled_stream.dart';
13 import 'package:scheduled_test/scheduled_test.dart';
14
15 import '../../io.dart';
16
17 void main() {
18 useSandbox();
19
20 test("ignores an empty file", () {
21 d.file("dart_test.yaml", "").create();
22
23 d.file("test.dart", """
24 import 'package:test/test.dart';
25
26 void main() {
27 test("success", () {});
28 }
29 """).create();
30
31 var test = runTest(["test.dart"]);
32 test.stdout.expect(consumeThrough(contains("+1: All tests passed!")));
33 test.shouldExit(0);
34 });
35
36 test("includes the full stack with verbose_trace: true", () {
37 d.file("dart_test.yaml", JSON.encode({
38 "verbose_trace": true
39 })).create();
40
41 d.file("test.dart", """
42 import 'package:test/test.dart';
43
44 void main() {
45 test("failure", () => throw "oh no");
46 }
47 """).create();
48
49 var test = runTest(["test.dart"], reporter: "compact");
50 test.stdout.expect(consumeThrough(contains("dart:isolate-patch")));
51 test.shouldExit(1);
52 });
53
54 test("doesn't dartify stack traces for JS-compiled tests with js_trace: true",
55 () {
56 d.file("dart_test.yaml", JSON.encode({
57 "js_trace": true
58 })).create();
59
60 d.file("test.dart", """
61 import 'package:test/test.dart';
62
63 void main() {
64 test("failure", () => throw "oh no");
65 }
66 """).create();
67
68 var test = runTest(["-p", "chrome", "--verbose-trace", "test.dart"]);
69 test.stdout.fork().expect(never(endsWith(" main.<fn>")));
70 test.stdout.fork().expect(never(contains("package:test")));
71 test.stdout.fork().expect(never(contains("dart:async/zone.dart")));
72 test.stdout.expect(consumeThrough(contains("-1: Some tests failed.")));
73 test.shouldExit(1);
74 });
75
76 test("uses the specified reporter", () {
77 d.file("dart_test.yaml", JSON.encode({
78 "reporter": "json"
79 })).create();
80
81 d.file("test.dart", """
82 import 'package:test/test.dart';
83
84 void main() {
85 test("success", () {});
86 }
87 """).create();
88
89 var test = runTest(["test.dart"]);
90 test.stdout.expect(consumeThrough(contains('"testStart"')));
91 test.shouldExit(0);
92 });
93
94 test("uses the specified pub serve port", () {
95 d.file("pubspec.yaml", """
96 name: myapp
97 dependencies:
98 barback: any
99 test: {path: ${p.current}}
100 transformers:
101 - myapp:
102 \$include: test/**_test.dart
103 - test/pub_serve:
104 \$include: test/**_test.dart
105 """).create();
106
107 d.dir("lib", [
108 d.file("myapp.dart", """
109 import 'package:barback/barback.dart';
110
111 class MyTransformer extends Transformer {
112 final allowedExtensions = '.dart';
113
114 MyTransformer.asPlugin();
115
116 Future apply(Transform transform) async {
117 var contents = await transform.primaryInput.readAsString();
118 transform.addOutput(new Asset.fromString(
119 transform.primaryInput.id,
120 contents.replaceAll("isFalse", "isTrue")));
121 }
122 }
123 """)
124 ]).create();
125
126 runPub(['get']).shouldExit(0);
127
128 d.dir("test", [
129 d.file("my_test.dart", """
130 import 'package:test/test.dart';
131
132 void main() {
133 test("success", () => expect(true, isFalse));
134 }
135 """)
136 ]).create();
137
138 var pub = runPubServe();
139
140 d.async(pubServePort.then((port) {
141 return d.file("dart_test.yaml", JSON.encode({
142 "pub_serve": port
143 }));
144 })).create();
145
146 var test = runTest([]);
147 test.stdout.expect(consumeThrough(contains('+1: All tests passed!')));
148 test.shouldExit(0);
149 pub.kill();
150 });
151
152 test("uses the specified concurrency", () {
153 d.file("dart_test.yaml", JSON.encode({
154 "concurrency": 2
155 })).create();
156
157 d.file("test.dart", """
158 import 'package:test/test.dart';
159
160 void main() {
161 test("success", () {});
162 }
163 """).create();
164
165 // We can't reliably test cthe concurrency, but this at least ensures that
166 // it doesn't fail to parse.
167 var test = runTest(["test.dart"]);
168 test.stdout.expect(consumeThrough(contains("+1: All tests passed!")));
169 test.shouldExit(0);
170 });
171
172 test("uses the specified timeout", () {
173 d.file("dart_test.yaml", JSON.encode({
174 "timeout": "0s"
175 })).create();
176
177 d.file("test.dart", """
178 import 'dart:async';
179
180 import 'package:test/test.dart';
181
182 void main() {
183 test("success", () => new Future.delayed(Duration.ZERO));
184 }
185 """).create();
186
187 var test = runTest(["test.dart"]);
188 test.stdout.expect(containsInOrder([
189 "Test timed out after 0 seconds.",
190 "-1: Some tests failed."
191 ]));
192 test.shouldExit(1);
193 });
194
195 test("runs on the specified platforms", () {
196 d.file("dart_test.yaml", JSON.encode({
197 "platforms": ["vm", "content-shell"]
198 })).create();
199
200 d.file("test.dart", """
201 import 'package:test/test.dart';
202
203 void main() {
204 test("success", () {});
205 }
206 """).create();
207
208 var test = runTest(["test.dart"]);
209 test.stdout.expect(containsInOrder([
210 "[VM] success",
211 "[Dartium Content Shell] success"
212 ]));
213 test.shouldExit(0);
214 });
215
216 test("command line args take precedence", () {
217 d.file("dart_test.yaml", JSON.encode({
218 "timeout": "0s"
219 })).create();
220
221 d.file("test.dart", """
222 import 'dart:async';
223
224 import 'package:test/test.dart';
225
226 void main() {
227 test("success", () => new Future.delayed(Duration.ZERO));
228 }
229 """).create();
230
231 var test = runTest(["--timeout=none", "test.dart"]);
232 test.stdout.expect(consumeThrough(contains("All tests passed!")));
233 test.shouldExit(0);
234 });
235 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698