| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "http_server.dart" as http_server; |
| 9 import "status_file_parser.dart"; |
| 8 import "test_runner.dart"; | 10 import "test_runner.dart"; |
| 9 import "test_suite.dart"; | 11 import "test_suite.dart"; |
| 10 import "status_file_parser.dart"; | 12 import "utils.dart"; |
| 11 import "http_server.dart" as http_server; | |
| 12 | 13 |
| 13 class ProgressIndicator { | 14 class ProgressIndicator { |
| 14 ProgressIndicator(this._startTime, this._printTiming) | 15 ProgressIndicator(this._startTime, this._printTiming) |
| 15 : _tests = [], _failureSummary = []; | 16 : _tests = [], _failureSummary = []; |
| 16 | 17 |
| 17 factory ProgressIndicator.fromName(String name, | 18 factory ProgressIndicator.fromName(String name, |
| 18 Date startTime, | 19 Date startTime, |
| 19 bool printTiming) { | 20 bool printTiming) { |
| 20 switch (name) { | 21 switch (name) { |
| 21 case 'compact': | 22 case 'compact': |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 prefix = ' '; | 182 prefix = ' '; |
| 182 } | 183 } |
| 183 } | 184 } |
| 184 if (!test.lastCommandOutput.stdout.isEmpty) { | 185 if (!test.lastCommandOutput.stdout.isEmpty) { |
| 185 output.add(''); | 186 output.add(''); |
| 186 output.add('stdout:'); | 187 output.add('stdout:'); |
| 187 if (test.lastCommandOutput.command.isPixelTest) { | 188 if (test.lastCommandOutput.command.isPixelTest) { |
| 188 output.add('DRT pixel test failed! stdout is not printed because it ' | 189 output.add('DRT pixel test failed! stdout is not printed because it ' |
| 189 'contains binary data!'); | 190 'contains binary data!'); |
| 190 } else { | 191 } else { |
| 191 output.add(new String.fromCharCodes(test.lastCommandOutput.stdout)); | 192 output.add(decodeUtf8(test.lastCommandOutput.stdout)); |
| 192 } | 193 } |
| 193 } | 194 } |
| 194 if (!test.lastCommandOutput.stderr.isEmpty) { | 195 if (!test.lastCommandOutput.stderr.isEmpty) { |
| 195 output.add(''); | 196 output.add(''); |
| 196 output.add('stderr:'); | 197 output.add('stderr:'); |
| 197 output.add(new String.fromCharCodes(test.lastCommandOutput.stderr)); | 198 output.add(decodeUtf8(test.lastCommandOutput.stderr)); |
| 198 } | 199 } |
| 199 if (test is BrowserTestCase) { | 200 if (test is BrowserTestCase) { |
| 200 // Additional command for rerunning the steps locally after the fact. | 201 // Additional command for rerunning the steps locally after the fact. |
| 201 output.add('To retest, run: ' | 202 output.add('To retest, run: ' |
| 202 '${TestUtils.dartTestExecutable.toNativePath()} ' | 203 '${TestUtils.dartTestExecutable.toNativePath()} ' |
| 203 '${TestUtils.dartDir().toNativePath()}/tools/testing/dart/' | 204 '${TestUtils.dartDir().toNativePath()}/tools/testing/dart/' |
| 204 'http_server.dart -m ${test.configuration["mode"]} ' | 205 'http_server.dart -m ${test.configuration["mode"]} ' |
| 205 '-a ${test.configuration["arch"]} ' | 206 '-a ${test.configuration["arch"]} ' |
| 206 '-p ${http_server.TestingServerRunner.serverList[0].port} ' | 207 '-p ${http_server.TestingServerRunner.serverList[0].port} ' |
| 207 '-c ${http_server.TestingServerRunner.serverList[1].port}'); | 208 '-c ${http_server.TestingServerRunner.serverList[1].port}'); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 : super(startTime, printTiming); | 330 : super(startTime, printTiming); |
| 330 | 331 |
| 331 static int BOLD = 1; | 332 static int BOLD = 1; |
| 332 static int GREEN = 32; | 333 static int GREEN = 32; |
| 333 static int RED = 31; | 334 static int RED = 31; |
| 334 static int NONE = 0; | 335 static int NONE = 0; |
| 335 | 336 |
| 336 addColorWrapped(List<int> codes, String string, int color) { | 337 addColorWrapped(List<int> codes, String string, int color) { |
| 337 codes.add(27); | 338 codes.add(27); |
| 338 codes.addAll('[${color}m'.charCodes); | 339 codes.addAll('[${color}m'.charCodes); |
| 339 codes.addAll(string.charCodes); | 340 codes.addAll(encodeUtf8(string)); |
| 340 codes.add(27); | 341 codes.add(27); |
| 341 codes.addAll('[0m'.charCodes); | 342 codes.addAll('[0m'.charCodes); |
| 342 } | 343 } |
| 343 | 344 |
| 344 void _printProgress() { | 345 void _printProgress() { |
| 345 var percent = ((_completedTests() / _foundTests) * 100).toInt().toString(); | 346 var percent = ((_completedTests() / _foundTests) * 100).toInt().toString(); |
| 346 var progressPadded = _pad(_allTestsKnown ? percent : '--', 3); | 347 var progressPadded = _pad(_allTestsKnown ? percent : '--', 3); |
| 347 var passedPadded = _pad(_passedTests.toString(), 5); | 348 var passedPadded = _pad(_passedTests.toString(), 5); |
| 348 var failedPadded = _pad(_failedTests.toString(), 5); | 349 var failedPadded = _pad(_failedTests.toString(), 5); |
| 349 Duration d = (new Date.now()).difference(_startTime); | 350 Duration d = (new Date.now()).difference(_startTime); |
| 350 var progressLine = []; | 351 var progressLine = []; |
| 351 progressLine.addAll('\r[${_timeString(d)} | $progressPadded% | '.charCodes); | 352 progressLine.addAll('\r[${_timeString(d)} | $progressPadded% | '.charCodes); |
| 352 addColorWrapped(progressLine, '+$passedPadded ', GREEN); | 353 addColorWrapped(progressLine, '+$passedPadded ', GREEN); |
| 353 progressLine.addAll('| '.charCodes); | 354 progressLine.addAll('| '.charCodes); |
| 354 var failedColor = (_failedTests != 0) ? RED : NONE; | 355 var failedColor = (_failedTests != 0) ? RED : NONE; |
| 355 addColorWrapped(progressLine, '-$failedPadded', failedColor); | 356 addColorWrapped(progressLine, '-$failedPadded', failedColor); |
| 356 progressLine.addAll(']'.charCodes); | 357 progressLine.addAll(']'.charCodes); |
| 357 stdout.write(progressLine); | 358 stdout.write(progressLine); |
| 358 } | 359 } |
| 359 | 360 |
| 360 String _header(String header) { | 361 String _header(String header) { |
| 361 var result = []; | 362 var result = []; |
| 362 addColorWrapped(result, header, BOLD); | 363 addColorWrapped(result, header, BOLD); |
| 363 return new String.fromCharCodes(result); | 364 return decodeUtf8(result); |
| 364 } | 365 } |
| 365 } | 366 } |
| 366 | 367 |
| 367 | 368 |
| 368 class LineProgressIndicator extends ProgressIndicator { | 369 class LineProgressIndicator extends ProgressIndicator { |
| 369 LineProgressIndicator(Date startTime, bool printTiming) | 370 LineProgressIndicator(Date startTime, bool printTiming) |
| 370 : super(startTime, printTiming); | 371 : super(startTime, printTiming); |
| 371 | 372 |
| 372 void _printStartProgress(TestCase test) { | 373 void _printStartProgress(TestCase test) { |
| 373 } | 374 } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 print(''); | 490 print(''); |
| 490 print('$config:'); | 491 print('$config:'); |
| 491 statuses.sort((a, b) => a.compareTo(b)); | 492 statuses.sort((a, b) => a.compareTo(b)); |
| 492 for (String status in statuses) { | 493 for (String status in statuses) { |
| 493 print(' $status'); | 494 print(' $status'); |
| 494 } | 495 } |
| 495 }); | 496 }); |
| 496 _printStatus(); | 497 _printStatus(); |
| 497 } | 498 } |
| 498 } | 499 } |
| OLD | NEW |