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

Side by Side Diff: test/runner/runner_test.dart

Issue 1097183003: Add an "onPlatform" parameter to test() and group(). (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 years, 8 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/browser/runner_test.dart ('k') | no next file » | 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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:io'; 7 import 'dart:io';
8 import 'dart:math' as math; 8 import 'dart:math' as math;
9 9
10 import 'package:path/path.dart' as p; 10 import 'package:path/path.dart' as p;
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 370
371 void main() { 371 void main() {
372 test("fail", () => throw 'oh no'); 372 test("fail", () => throw 'oh no');
373 } 373 }
374 '''); 374 ''');
375 375
376 var result = _runUnittest(["test.dart"]); 376 var result = _runUnittest(["test.dart"]);
377 expect(result.stdout, contains("+0 ~1: All tests skipped.")); 377 expect(result.stdout, contains("+0 ~1: All tests skipped."));
378 }); 378 });
379 379
380 group("in onPlatform", () {
381 test("respects matching Skips", () {
382 new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
383 import 'dart:async';
384
385 import 'package:test/test.dart';
386
387 void main() {
388 test("fail", () => throw 'oh no', onPlatform: {"vm": new Skip()});
389 }
390 ''');
391
392 var result = _runUnittest(["test.dart"]);
393 expect(result.stdout, contains("+0 ~1: All tests skipped."));
394 });
395
396 test("ignores non-matching Skips", () {
397 new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
398 import 'dart:async';
399
400 import 'package:test/test.dart';
401
402 void main() {
403 test("success", () {}, onPlatform: {"chrome": new Skip()});
404 }
405 ''');
406
407 var result = _runUnittest(["test.dart"]);
408 expect(result.stdout, contains("+1: All tests passed!"));
409 });
410
411 test("respects matching Timeouts", () {
412 new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
413 import 'dart:async';
414
415 import 'package:test/test.dart';
416
417 void main() {
418 test("fail", () => throw 'oh no', onPlatform: {
419 "vm": new Timeout(new Duration(seconds: 0))
420 });
421 }
422 ''');
423
424 var result = _runUnittest(["test.dart"]);
425 expect(result.stdout, contains("Test timed out after 0 seconds."));
426 expect(result.stdout, contains("-1: Some tests failed."));
427 });
428
429 test("ignores non-matching Timeouts", () {
430 new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
431 import 'dart:async';
432
433 import 'package:test/test.dart';
434
435 void main() {
436 test("success", () {}, onPlatform: {
437 "chrome": new Timeout(new Duration(seconds: 0))
438 });
439 }
440 ''');
441
442 var result = _runUnittest(["test.dart"]);
443 expect(result.stdout, contains("+1: All tests passed!"));
444 });
445
446 test("applies matching platforms in order", () {
447 new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
448 import 'dart:async';
449
450 import 'package:test/test.dart';
451
452 void main() {
453 test("success", () {}, onPlatform: {
454 "vm": new Skip("first"),
455 "vm || windows": new Skip("second"),
456 "vm || linux": new Skip("third"),
457 "vm || mac-os": new Skip("fourth"),
458 "vm || android": new Skip("fifth")
459 });
460 }
461 ''');
462
463 var result = _runUnittest(["test.dart"]);
464 expect(result.stdout, contains("Skip: fifth"));
465 expect(result.stdout, isNot(anyOf([
466 contains("Skip: first"),
467 contains("Skip: second"),
468 contains("Skip: third"),
469 contains("Skip: fourth")
470 ])));
471 });
472 });
473
380 group("flags:", () { 474 group("flags:", () {
381 test("with the --color flag, uses colors", () { 475 test("with the --color flag, uses colors", () {
382 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(_failure); 476 new File(p.join(_sandbox, "test.dart")).writeAsStringSync(_failure);
383 var result = _runUnittest(["--color", "test.dart"]); 477 var result = _runUnittest(["--color", "test.dart"]);
384 // This is the color code for red. 478 // This is the color code for red.
385 expect(result.stdout, contains("\u001b[31m")); 479 expect(result.stdout, contains("\u001b[31m"));
386 }); 480 });
387 481
388 group("with the --name flag,", () { 482 group("with the --name flag,", () {
389 test("selects tests with matching names", () { 483 test("selects tests with matching names", () {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 }); 582 });
489 }); 583 });
490 }); 584 });
491 } 585 }
492 586
493 ProcessResult _runUnittest(List<String> args) => 587 ProcessResult _runUnittest(List<String> args) =>
494 runUnittest(args, workingDirectory: _sandbox); 588 runUnittest(args, workingDirectory: _sandbox);
495 589
496 ProcessResult _runDart(List<String> args) => 590 ProcessResult _runDart(List<String> args) =>
497 runDart(args, workingDirectory: _sandbox); 591 runDart(args, workingDirectory: _sandbox);
OLDNEW
« no previous file with comments | « test/runner/browser/runner_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698