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

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

Issue 1715523003: Warn when an unsupported platform is passed. (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
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 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 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 'dart:convert'; 7 import 'dart:convert';
8 8
9 import 'package:path/path.dart' as p; 9 import 'package:path/path.dart' as p;
10 import 'package:scheduled_test/descriptor.dart' as d; 10 import 'package:scheduled_test/descriptor.dart' as d;
11 import 'package:scheduled_test/scheduled_stream.dart'; 11 import 'package:scheduled_test/scheduled_stream.dart';
12 import 'package:scheduled_test/scheduled_test.dart'; 12 import 'package:scheduled_test/scheduled_test.dart';
13 import 'package:test/src/util/io.dart';
13 14
14 import '../../io.dart'; 15 import '../../io.dart';
15 16
16 void main() { 17 void main() {
17 useSandbox(); 18 useSandbox();
18 19
19 test("ignores an empty file", () { 20 test("ignores an empty file", () {
20 d.file("dart_test.yaml", "").create(); 21 d.file("dart_test.yaml", "").create();
21 22
22 d.file("test.dart", """ 23 d.file("test.dart", """
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 test("test", () {}); 103 test("test", () {});
103 } 104 }
104 """).create(); 105 """).create();
105 106
106 var test = runTest(["test.dart"]); 107 var test = runTest(["test.dart"]);
107 test.stdout.expect(consumeThrough(contains('Tests are boring.'))); 108 test.stdout.expect(consumeThrough(contains('Tests are boring.')));
108 test.stdout.expect(consumeThrough(contains('All tests skipped.'))); 109 test.stdout.expect(consumeThrough(contains('All tests skipped.')));
109 test.shouldExit(0); 110 test.shouldExit(0);
110 }); 111 });
111 112
112 test("runs tests on a platform that matches test_on", () { 113 group("test_on", () {
113 d.file("dart_test.yaml", JSON.encode({ 114 test("runs tests on a platform matching platform", () {
114 "test_on": "vm" 115 d.file("dart_test.yaml", JSON.encode({
115 })).create(); 116 "test_on": "vm"
117 })).create();
116 118
117 d.file("test.dart", """ 119 d.file("test.dart", """
118 import 'package:test/test.dart'; 120 import 'package:test/test.dart';
119 121
120 void main() { 122 void main() {
121 test("test", () {}); 123 test("test", () {});
122 } 124 }
123 """).create(); 125 """).create();
124 126
125 var test = runTest(["test.dart"]); 127 var test = runTest(["test.dart"]);
126 test.stdout.expect(consumeThrough(contains('All tests passed!'))); 128 test.stdout.expect(consumeThrough(contains('All tests passed!')));
127 test.shouldExit(0); 129 test.shouldExit(0);
128 }); 130 });
129 131
130 test("doesn't run tests on a platform that doesn't match test_on", () { 132 test("warns about the VM when no OSes are supported", () {
131 d.file("dart_test.yaml", JSON.encode({ 133 d.file("dart_test.yaml", JSON.encode({
132 "test_on": "chrome" 134 "test_on": "chrome"
133 })).create(); 135 })).create();
134 136
135 d.file("test.dart", """ 137 d.file("test.dart", """
136 import 'package:test/test.dart'; 138 import 'package:test/test.dart';
137 139
138 void main() { 140 void main() {
139 test("test", () {}); 141 test("test", () {});
140 } 142 }
141 """).create(); 143 """).create();
142 144
143 var test = runTest(["test.dart"]); 145 var test = runTest(["test.dart"]);
144 test.stdout.expect(consumeThrough(contains('No tests ran.'))); 146 test.stderr.expect(
145 test.shouldExit(0); 147 "Warning: this package doesn't support running tests on the Dart "
148 "VM.");
149 test.stdout.expect(consumeThrough(contains('No tests ran.')));
150 test.shouldExit(0);
151 });
152
153 test("warns about the OS when some OSes are supported", () {
154 d.file("dart_test.yaml", JSON.encode({
155 "test_on": otherOS
156 })).create();
157
158 d.file("test.dart", """
159 import 'package:test/test.dart';
160
161 void main() {
162 test("test", () {});
163 }
164 """).create();
165
166 var test = runTest(["test.dart"]);
167 test.stderr.expect(
168 "Warning: this package doesn't support running tests on "
169 "${currentOS.name}.");
170 test.stdout.expect(consumeThrough(contains('No tests ran.')));
171 test.shouldExit(0);
172 });
173
174 test("warns about browsers in general when no browsers are supported", () {
175 d.file("dart_test.yaml", JSON.encode({
176 "test_on": "vm"
177 })).create();
178
179 d.file("test.dart", """
180 import 'package:test/test.dart';
181
182 void main() {
183 test("test", () {});
184 }
185 """).create();
186
187 var test = runTest(["-p", "chrome", "test.dart"]);
188 test.stderr.expect(
189 "Warning: this package doesn't support running tests on browsers.");
190 test.stdout.expect(consumeThrough(contains('No tests ran.')));
191 test.shouldExit(0);
192 });
193
194 test("warns about specific browsers when specific browsers are "
195 "supported", () {
196 d.file("dart_test.yaml", JSON.encode({
197 "test_on": "safari"
198 })).create();
199
200 d.file("test.dart", """
201 import 'package:test/test.dart';
202
203 void main() {
204 test("test", () {});
205 }
206 """).create();
207
208 var test = runTest(["-p", "chrome,firefox,phantomjs", "test.dart"]);
209 test.stderr.expect(
210 "Warning: this package doesn't support running tests on Chrome, "
211 "Firefox, or PhantomJS.");
212 test.stdout.expect(consumeThrough(contains('No tests ran.')));
213 test.shouldExit(0);
214 });
146 }); 215 });
147 216
148 test("uses the specified reporter", () { 217 test("uses the specified reporter", () {
149 d.file("dart_test.yaml", JSON.encode({ 218 d.file("dart_test.yaml", JSON.encode({
150 "reporter": "json" 219 "reporter": "json"
151 })).create(); 220 })).create();
152 221
153 d.file("test.dart", """ 222 d.file("test.dart", """
154 import 'package:test/test.dart'; 223 import 'package:test/test.dart';
155 224
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 test("failure", () => throw "oh no"); 443 test("failure", () => throw "oh no");
375 } 444 }
376 """) 445 """)
377 ]).create(); 446 ]).create();
378 447
379 var test = runTest([]); 448 var test = runTest([]);
380 test.stdout.expect(consumeThrough(contains('All tests passed!'))); 449 test.stdout.expect(consumeThrough(contains('All tests passed!')));
381 test.shouldExit(0); 450 test.shouldExit(0);
382 }); 451 });
383 } 452 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698