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

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

Issue 1782473005: Add support for configuration presets. (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 | « pubspec.yaml ('k') | test/runner/configuration/platform_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
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 'package:boolean_selector/boolean_selector.dart'; 7 import 'package:boolean_selector/boolean_selector.dart';
8 import 'package:path/path.dart' as p; 8 import 'package:path/path.dart' as p;
9 import 'package:test/test.dart'; 9 import 'package:test/test.dart';
10 10
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 excludeTags: new BooleanSelector.parse("qux")); 222 excludeTags: new BooleanSelector.parse("qux"));
223 var merged = older.merge(newer); 223 var merged = older.merge(newer);
224 224
225 expect(merged.includeTags, 225 expect(merged.includeTags,
226 equals(new BooleanSelector.parse("(foo || bar) && blip"))); 226 equals(new BooleanSelector.parse("(foo || bar) && blip")));
227 expect(merged.excludeTags, 227 expect(merged.excludeTags,
228 equals(new BooleanSelector.parse("(baz || bang) || qux"))); 228 equals(new BooleanSelector.parse("(baz || bang) || qux")));
229 }); 229 });
230 }); 230 });
231 231
232 group("for tags", () { 232 group("for sets", () {
233 test("merges each nested configuration", () { 233 test("if neither is defined, preserves the default", () {
234 var merged = new Configuration().merge(new Configuration());
235 expect(merged.addTags, isEmpty);
236 expect(merged.chosenPresets, isEmpty);
237 });
238
239 test("if only the old configuration's is defined, uses it", () {
234 var merged = new Configuration( 240 var merged = new Configuration(
235 tags: { 241 addTags: new Set.from(["foo", "bar"]),
236 new BooleanSelector.parse("foo"): 242 chosenPresets: new Set.from(["baz", "bang"]))
237 new Configuration(verboseTrace: true), 243 .merge(new Configuration());
238 new BooleanSelector.parse("bar"): new Configuration(jsTrace: true)
239 }
240 ).merge(new Configuration(
241 tags: {
242 new BooleanSelector.parse("bar"): new Configuration(jsTrace: false),
243 new BooleanSelector.parse("baz"): new Configuration(skip: true)
244 }
245 ));
246 244
247 expect(merged.tags[new BooleanSelector.parse("foo")].verboseTrace, 245 expect(merged.addTags, unorderedEquals(["foo", "bar"]));
248 isTrue); 246 expect(merged.chosenPresets, equals(["baz", "bang"]));
249 expect(merged.tags[new BooleanSelector.parse("bar")].jsTrace, isFalse); 247 });
250 expect(merged.tags[new BooleanSelector.parse("baz")].skip, isTrue); 248
249 test("if only the new configuration's is defined, uses it", () {
250 var merged = new Configuration().merge(new Configuration(
251 addTags: new Set.from(["foo", "bar"]),
252 chosenPresets: new Set.from(["baz", "bang"])));
253
254 expect(merged.addTags, unorderedEquals(["foo", "bar"]));
255 expect(merged.chosenPresets, equals(["baz", "bang"]));
256 });
257
258 test("if both are defined, unions them", () {
259 var older = new Configuration(
260 addTags: new Set.from(["foo", "bar"]),
261 chosenPresets: new Set.from(["baz", "bang"]));
262 var newer = new Configuration(
263 addTags: new Set.from(["blip"]),
264 chosenPresets: new Set.from(["qux"]));
265 var merged = older.merge(newer);
266
267 expect(merged.addTags, unorderedEquals(["foo", "bar", "blip"]));
268 expect(merged.chosenPresets, equals(["baz", "bang", "qux"]));
251 }); 269 });
252 }); 270 });
253 271
254 group("for timeout", () { 272 group("for timeout", () {
255 test("if neither is defined, preserves the default", () { 273 test("if neither is defined, preserves the default", () {
256 var merged = new Configuration().merge(new Configuration()); 274 var merged = new Configuration().merge(new Configuration());
257 expect(merged.timeout, equals(new Timeout.factor(1))); 275 expect(merged.timeout, equals(new Timeout.factor(1)));
258 }); 276 });
259 277
260 test("if only the old configuration's is defined, uses it", () { 278 test("if only the old configuration's is defined, uses it", () {
(...skipping 18 matching lines...) Expand all
279 test("if the merge conflicts, prefers the new value", () { 297 test("if the merge conflicts, prefers the new value", () {
280 var older = new Configuration( 298 var older = new Configuration(
281 timeout: new Timeout(new Duration(seconds: 1))); 299 timeout: new Timeout(new Duration(seconds: 1)));
282 var newer = new Configuration( 300 var newer = new Configuration(
283 timeout: new Timeout(new Duration(seconds: 2))); 301 timeout: new Timeout(new Duration(seconds: 2)));
284 var merged = older.merge(newer); 302 var merged = older.merge(newer);
285 expect(merged.timeout, equals(new Timeout(new Duration(seconds: 2)))); 303 expect(merged.timeout, equals(new Timeout(new Duration(seconds: 2))));
286 }); 304 });
287 }); 305 });
288 306
289 group("for onPlatform", () { 307 group("for config maps", () {
290 test("merges each nested configuration", () { 308 test("merges each nested configuration", () {
291 var merged = new Configuration( 309 var merged = new Configuration(
310 tags: {
311 new BooleanSelector.parse("foo"):
312 new Configuration(verboseTrace: true),
313 new BooleanSelector.parse("bar"): new Configuration(jsTrace: true)
314 },
292 onPlatform: { 315 onPlatform: {
293 new PlatformSelector.parse("vm"): new Configuration(verboseTrace: tr ue), 316 new PlatformSelector.parse("vm"):
294 new PlatformSelector.parse("chrome"): new Configuration(jsTrace: tru e) 317 new Configuration(verboseTrace: true),
318 new PlatformSelector.parse("chrome"):
319 new Configuration(jsTrace: true)
320 },
321 presets: {
322 "bang": new Configuration(verboseTrace: true),
323 "qux": new Configuration(jsTrace: true)
295 } 324 }
296 ).merge(new Configuration( 325 ).merge(new Configuration(
326 tags: {
327 new BooleanSelector.parse("bar"): new Configuration(jsTrace: false),
328 new BooleanSelector.parse("baz"): new Configuration(skip: true)
329 },
297 onPlatform: { 330 onPlatform: {
298 new PlatformSelector.parse("chrome"): new Configuration(jsTrace: fal se), 331 new PlatformSelector.parse("chrome"):
332 new Configuration(jsTrace: false),
299 new PlatformSelector.parse("firefox"): new Configuration(skip: true) 333 new PlatformSelector.parse("firefox"): new Configuration(skip: true)
334 },
335 presets: {
336 "qux": new Configuration(jsTrace: false),
337 "zap": new Configuration(skip: true)
300 } 338 }
301 )); 339 ));
302 340
341 expect(merged.tags[new BooleanSelector.parse("foo")].verboseTrace,
342 isTrue);
343 expect(merged.tags[new BooleanSelector.parse("bar")].jsTrace, isFalse);
344 expect(merged.tags[new BooleanSelector.parse("baz")].skip, isTrue);
345
303 expect(merged.onPlatform[new PlatformSelector.parse("vm")].verboseTrace, 346 expect(merged.onPlatform[new PlatformSelector.parse("vm")].verboseTrace,
304 isTrue); 347 isTrue);
305 expect(merged.onPlatform[new PlatformSelector.parse("chrome")].jsTrace, 348 expect(merged.onPlatform[new PlatformSelector.parse("chrome")].jsTrace,
306 isFalse); 349 isFalse);
307 expect(merged.onPlatform[new PlatformSelector.parse("firefox")].skip, 350 expect(merged.onPlatform[new PlatformSelector.parse("firefox")].skip,
308 isTrue); 351 isTrue);
352
353 expect(merged.presets["bang"].verboseTrace, isTrue);
354 expect(merged.presets["qux"].jsTrace, isFalse);
355 expect(merged.presets["zap"].skip, isTrue);
356 });
357 });
358
359 group("for presets", () {
360 test("automatically resolves a matching chosen preset", () {
361 var configuration = new Configuration(
362 presets: {"foo": new Configuration(verboseTrace: true)},
363 chosenPresets: ["foo"]);
364 expect(configuration.presets, isEmpty);
365 expect(configuration.chosenPresets, equals(["foo"]));
366 expect(configuration.knownPresets, equals(["foo"]));
367 expect(configuration.verboseTrace, isTrue);
368 });
369
370 test("resolves a chosen presets in order", () {
371 var configuration = new Configuration(
372 presets: {
373 "foo": new Configuration(verboseTrace: true),
374 "bar": new Configuration(verboseTrace: false)
375 },
376 chosenPresets: ["foo", "bar"]);
377 expect(configuration.presets, isEmpty);
378 expect(configuration.chosenPresets, equals(["foo", "bar"]));
379 expect(configuration.knownPresets, unorderedEquals(["foo", "bar"]));
380 expect(configuration.verboseTrace, isFalse);
381
382 configuration = new Configuration(
383 presets: {
384 "foo": new Configuration(verboseTrace: true),
385 "bar": new Configuration(verboseTrace: false)
386 },
387 chosenPresets: ["bar", "foo"]);
388 expect(configuration.presets, isEmpty);
389 expect(configuration.chosenPresets, equals(["bar", "foo"]));
390 expect(configuration.knownPresets, unorderedEquals(["foo", "bar"]));
391 expect(configuration.verboseTrace, isTrue);
392 });
393
394 test("ignores inapplicable chosen presets", () {
395 var configuration = new Configuration(
396 presets: {},
397 chosenPresets: ["baz"]);
398 expect(configuration.presets, isEmpty);
399 expect(configuration.chosenPresets, equals(["baz"]));
400 expect(configuration.knownPresets, equals(isEmpty));
401 });
402
403 test("resolves presets through merging", () {
404 var configuration = new Configuration(presets: {
405 "foo": new Configuration(verboseTrace: true)
406 }).merge(new Configuration(chosenPresets: ["foo"]));
407
408 expect(configuration.presets, isEmpty);
409 expect(configuration.chosenPresets, equals(["foo"]));
410 expect(configuration.knownPresets, equals(["foo"]));
411 expect(configuration.verboseTrace, isTrue);
412 });
413
414 test("preserves known presets through merging", () {
415 var configuration = new Configuration(presets: {
416 "foo": new Configuration(verboseTrace: true)
417 }, chosenPresets: ["foo"])
418 .merge(new Configuration());
419
420 expect(configuration.presets, isEmpty);
421 expect(configuration.chosenPresets, equals(["foo"]));
422 expect(configuration.knownPresets, equals(["foo"]));
423 expect(configuration.verboseTrace, isTrue);
309 }); 424 });
310 }); 425 });
311 }); 426 });
312 } 427 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | test/runner/configuration/platform_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698