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

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

Issue 2099553002: Add an option to run skipped tests. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 4 years, 5 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 | « lib/src/runner/reporter/json.dart ('k') | test/runner/configuration/configuration_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) 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 'package:scheduled_test/descriptor.dart' as d; 7 import 'package:scheduled_test/descriptor.dart' as d;
8 import 'package:scheduled_test/scheduled_stream.dart'; 8 import 'package:scheduled_test/scheduled_stream.dart';
9 import 'package:scheduled_test/scheduled_test.dart'; 9 import 'package:scheduled_test/scheduled_test.dart';
10 10
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 324
325 test("displays a skipped group", () { 325 test("displays a skipped group", () {
326 _expectReport(""" 326 _expectReport("""
327 group('skip', () { 327 group('skip', () {
328 test('test 1', () {}); 328 test('test 1', () {});
329 test('test 2', () {}); 329 test('test 2', () {});
330 test('test 3', () {}); 330 test('test 3', () {});
331 }, skip: true);""", 331 }, skip: true);""",
332 """ 332 """
333 +0: loading test.dart 333 +0: loading test.dart
334 +0: skip 334 +0: skip test 1
335 +0 ~1: skip 335 +0 ~1: skip test 1
336 +0 ~1: All tests skipped."""); 336 +0 ~1: skip test 2
337 +0 ~2: skip test 2
338 +0 ~2: skip test 3
339 +0 ~3: skip test 3
340 +0 ~3: All tests skipped.""");
337 }); 341 });
338 342
339 test("runs skipped tests along with successful tests", () { 343 test("runs skipped tests along with successful tests", () {
340 _expectReport(""" 344 _expectReport("""
341 test('skip 1', () {}, skip: true); 345 test('skip 1', () {}, skip: true);
342 test('success 1', () {}); 346 test('success 1', () {});
343 test('skip 2', () {}, skip: true); 347 test('skip 2', () {}, skip: true);
344 test('success 2', () {});""", 348 test('success 2', () {});""",
345 """ 349 """
346 +0: loading test.dart 350 +0: loading test.dart
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 +0: skip 1 401 +0: skip 1
398 Skip: some reason 402 Skip: some reason
399 403
400 +0 ~1: skip 1 404 +0 ~1: skip 1
401 +0 ~1: skip 2 405 +0 ~1: skip 2
402 Skip: or another 406 Skip: or another
403 407
404 +0 ~2: skip 2 408 +0 ~2: skip 2
405 +0 ~2: All tests skipped."""); 409 +0 ~2: All tests skipped.""");
406 }); 410 });
411
412 test("runs skipped tests with --run-skipped", () {
413 _expectReport("""
414 test('skip 1', () {}, skip: 'some reason');
415 test('skip 2', () {}, skip: 'or another');""",
416 """
417 +0: loading test.dart
418 +0: skip 1
419 +1: skip 1
420 +1: skip 2
421 +2: skip 2
422 +2: All tests passed!""",
423 args: ["--run-skipped"]);
424 });
407 }); 425 });
408 } 426 }
409 427
410 void _expectReport(String tests, String expected) { 428 void _expectReport(String tests, String expected, {List<String> args}) {
411 var dart = """ 429 var dart = """
412 import 'dart:async'; 430 import 'dart:async';
413 431
414 import 'package:test/test.dart'; 432 import 'package:test/test.dart';
415 433
416 void main() { 434 void main() {
417 $tests 435 $tests
418 } 436 }
419 """; 437 """;
420 438
421 d.file("test.dart", dart).create(); 439 d.file("test.dart", dart).create();
422 440
423 var test = runTest(["test.dart"], reporter: "compact"); 441 var test = runTest(["test.dart"]..addAll(args ?? []), reporter: "compact");
424 test.shouldExit(); 442 test.shouldExit();
425 443
426 schedule(() async { 444 schedule(() async {
427 var stdoutLines = await test.stdoutStream().toList(); 445 var stdoutLines = await test.stdoutStream().toList();
428 446
429 // Skip the first CR, remove excess trailing whitespace, and trim off 447 // Skip the first CR, remove excess trailing whitespace, and trim off
430 // timestamps. 448 // timestamps.
431 var lastLine; 449 var lastLine;
432 var actual = stdoutLines.skip(1).map((line) { 450 var actual = stdoutLines.skip(1).map((line) {
433 if (line.startsWith(" ") || line.isEmpty) return line.trimRight(); 451 if (line.startsWith(" ") || line.isEmpty) return line.trimRight();
(...skipping 11 matching lines...) Expand all
445 // Un-indent the expected string. 463 // Un-indent the expected string.
446 var indentation = expected.indexOf(new RegExp("[^ ]")); 464 var indentation = expected.indexOf(new RegExp("[^ ]"));
447 expected = expected.split("\n").map((line) { 465 expected = expected.split("\n").map((line) {
448 if (line.isEmpty) return line; 466 if (line.isEmpty) return line;
449 return line.substring(indentation); 467 return line.substring(indentation);
450 }).join("\n"); 468 }).join("\n");
451 469
452 expect(actual, equals(expected)); 470 expect(actual, equals(expected));
453 }); 471 });
454 } 472 }
OLDNEW
« no previous file with comments | « lib/src/runner/reporter/json.dart ('k') | test/runner/configuration/configuration_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698