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

Side by Side Diff: tools/testing/dart/test_progress.dart

Issue 14718005: Print the number of failed tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library test_progress; 5 library test_progress;
6 6
7 import "dart:io"; 7 import "dart:io";
8 import "dart:io" as io; 8 import "dart:io" as io;
9 import "http_server.dart" as http_server; 9 import "http_server.dart" as http_server;
10 import "status_file_parser.dart"; 10 import "status_file_parser.dart";
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 121 }
122 for (Command c in test.commands) { 122 for (Command c in test.commands) {
123 output.add(''); 123 output.add('');
124 String message = (c == test.commands.last 124 String message = (c == test.commands.last
125 ? "Command line" : "Compilation command"); 125 ? "Command line" : "Compilation command");
126 output.add('$message: $c'); 126 output.add('$message: $c');
127 } 127 }
128 return output; 128 return output;
129 } 129 }
130 130
131 String _buildSummaryEnd(int failedTests) {
132 if (failedTests == 0) {
133 return '\n===\n=== All tests succeeded\n===\n';
134 } else {
135 var pluralSuffix = failedTests != 1 ? 's' : '';
136 return '\n===\n=== ${failedTests} test$pluralSuffix failed\n===\n';
137 }
138 }
139
131 140
132 class EventListener { 141 class EventListener {
133 void testAdded() { } 142 void testAdded() { }
134 void start(TestCase test) { } 143 void start(TestCase test) { }
135 void done(TestCase test) { } 144 void done(TestCase test) { }
136 void allTestsKnown() { } 145 void allTestsKnown() { }
137 void allDone() { } 146 void allDone() { }
138 } 147 }
139 148
140 class ExitCodeSetter extends EventListener { 149 class ExitCodeSetter extends EventListener {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 status = 'fail'; 326 status = 'fail';
318 } 327 }
319 print('Done ${test.configurationString} ${test.displayName}: $status'); 328 print('Done ${test.configurationString} ${test.displayName}: $status');
320 } 329 }
321 } 330 }
322 331
323 class TestFailurePrinter extends EventListener { 332 class TestFailurePrinter extends EventListener {
324 bool _printSummary; 333 bool _printSummary;
325 var _formatter; 334 var _formatter;
326 var _failureSummary = <String>[]; 335 var _failureSummary = <String>[];
336 var _failedTests= 0;
327 337
328 TestFailurePrinter(this._printSummary, 338 TestFailurePrinter(this._printSummary,
329 [this._formatter = const Formatter()]); 339 [this._formatter = const Formatter()]);
330 340
331 void done(TestCase test) { 341 void done(TestCase test) {
332 if (test.lastCommandOutput.unexpectedOutput) { 342 if (test.lastCommandOutput.unexpectedOutput) {
343 _failedTests++;
333 var lines = _buildFailureOutput(test, _formatter); 344 var lines = _buildFailureOutput(test, _formatter);
334 for (var line in lines) { 345 for (var line in lines) {
335 print(line); 346 print(line);
336 } 347 }
337 print(''); 348 print('');
338 if (_printSummary) { 349 if (_printSummary) {
339 _failureSummary.addAll(lines); 350 _failureSummary.addAll(lines);
340 _failureSummary.add(''); 351 _failureSummary.add('');
341 } 352 }
342 } 353 }
343 } 354 }
344 355
345 void allDone() { 356 void allDone() {
346 if (_printSummary) { 357 if (_printSummary) {
347 if (!_failureSummary.isEmpty) { 358 if (!_failureSummary.isEmpty) {
348 print('\n=== Failure summary:\n'); 359 print('\n=== Failure summary:\n');
349 for (String line in _failureSummary) { 360 for (String line in _failureSummary) {
350 print(line); 361 print(line);
351 } 362 }
352 print(''); 363 print('');
364
365 print(_buildSummaryEnd(_failedTests));
kustermann 2013/05/02 14:13:00 If we want to print it always (not just if somethi
353 } 366 }
354 } 367 }
355 } 368 }
356 } 369 }
357 370
358 class ProgressIndicator extends EventListener { 371 class ProgressIndicator extends EventListener {
359 ProgressIndicator(this._startTime); 372 ProgressIndicator(this._startTime);
360 373
361 factory ProgressIndicator.fromName(String name, 374 factory ProgressIndicator.fromName(String name,
362 DateTime startTime, 375 DateTime startTime,
(...skipping 27 matching lines...) Expand all
390 } else { 403 } else {
391 _passedTests++; 404 _passedTests++;
392 } 405 }
393 _printDoneProgress(test); 406 _printDoneProgress(test);
394 } 407 }
395 408
396 void allTestsKnown() { 409 void allTestsKnown() {
397 _allTestsKnown = true; 410 _allTestsKnown = true;
398 } 411 }
399 412
400 void allDone() {
401 _printStatus();
402 }
403
404 void _printStartProgress(TestCase test) {} 413 void _printStartProgress(TestCase test) {}
405 void _printDoneProgress(TestCase test) {} 414 void _printDoneProgress(TestCase test) {}
406 415
407 void _printStatus() {
408 if (_failedTests == 0) {
409 print('\n===');
410 print('=== All tests succeeded');
411 print('===\n');
412 } else {
413 var pluralSuffix = _failedTests != 1 ? 's' : '';
414 print('\n===');
415 print('=== ${_failedTests} test$pluralSuffix failed');
416 print('===\n');
417 }
418 }
419
420 int get numFailedTests => _failedTests;
421
422 int _completedTests() => _passedTests + _failedTests; 416 int _completedTests() => _passedTests + _failedTests;
423 417
424 int _foundTests = 0; 418 int _foundTests = 0;
425 int _passedTests = 0; 419 int _passedTests = 0;
426 int _failedTests = 0; 420 int _failedTests = 0;
427 bool _allTestsKnown = false; 421 bool _allTestsKnown = false;
428 DateTime _startTime; 422 DateTime _startTime;
429 } 423 }
430 424
431 abstract class CompactIndicator extends ProgressIndicator { 425 abstract class CompactIndicator extends ProgressIndicator {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 if (!_failureSummary.isEmpty) { 508 if (!_failureSummary.isEmpty) {
515 print('@@@STEP_FAILURE@@@'); 509 print('@@@STEP_FAILURE@@@');
516 if (stepName != null) { 510 if (stepName != null) {
517 print('@@@BUILD_STEP $stepName failures@@@'); 511 print('@@@BUILD_STEP $stepName failures@@@');
518 } 512 }
519 for (String line in _failureSummary) { 513 for (String line in _failureSummary) {
520 print(line); 514 print(line);
521 } 515 }
522 print(''); 516 print('');
523 } 517 }
524 super.allDone(); 518 print(_buildSummaryEnd(_failedTests));
525 } 519 }
526 } 520 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698