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("test_runner.dart"); | 8 #import("test_runner.dart"); |
9 #import("test_suite.dart"); | 9 #import("test_suite.dart"); |
10 | 10 |
11 class ProgressIndicator { | 11 class ProgressIndicator { |
12 ProgressIndicator(this._startTime, this._printTiming) | 12 ProgressIndicator(this._startTime, this._printTiming) |
13 : _tests = [], _failureSummary = []; | 13 : _tests = [], _failureSummary = []; |
14 | 14 |
15 factory ProgressIndicator.fromName(String name, | 15 factory ProgressIndicator.fromName(String name, |
16 Date startTime, | 16 Date startTime, |
17 bool printTiming) { | 17 bool printTiming, |
| 18 String stepName) { |
18 switch (name) { | 19 switch (name) { |
19 case 'compact': | 20 case 'compact': |
20 return new CompactProgressIndicator(startTime, printTiming); | 21 return new CompactProgressIndicator(startTime, printTiming); |
21 case 'color': | 22 case 'color': |
22 return new ColorProgressIndicator(startTime, printTiming); | 23 return new ColorProgressIndicator(startTime, printTiming); |
23 case 'line': | 24 case 'line': |
24 return new LineProgressIndicator(startTime, printTiming); | 25 return new LineProgressIndicator(startTime, printTiming); |
25 case 'verbose': | 26 case 'verbose': |
26 return new VerboseProgressIndicator(startTime, printTiming); | 27 return new VerboseProgressIndicator(startTime, printTiming); |
27 case 'silent': | 28 case 'silent': |
28 return new SilentProgressIndicator(startTime, printTiming); | 29 return new SilentProgressIndicator(startTime, printTiming); |
29 case 'status': | 30 case 'status': |
30 return new StatusProgressIndicator(startTime, printTiming); | 31 return new StatusProgressIndicator(startTime, printTiming); |
31 case 'buildbot': | 32 case 'buildbot': |
32 return new BuildbotProgressIndicator(startTime, printTiming); | 33 return new BuildbotProgressIndicator(startTime, printTiming, stepName); |
33 default: | 34 default: |
34 assert(false); | 35 assert(false); |
35 break; | 36 break; |
36 } | 37 } |
37 } | 38 } |
38 | 39 |
39 void testAdded() { _foundTests++; } | 40 void testAdded() { _foundTests++; } |
40 | 41 |
41 void start(TestCase test) { | 42 void start(TestCase test) { |
42 _printStartProgress(test); | 43 _printStartProgress(test); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 | 334 |
334 void _printStartProgress(TestCase test) { | 335 void _printStartProgress(TestCase test) { |
335 } | 336 } |
336 | 337 |
337 void _printDoneProgress(TestCase test) { | 338 void _printDoneProgress(TestCase test) { |
338 } | 339 } |
339 } | 340 } |
340 | 341 |
341 | 342 |
342 class BuildbotProgressIndicator extends ProgressIndicator { | 343 class BuildbotProgressIndicator extends ProgressIndicator { |
343 BuildbotProgressIndicator(Date startTime, bool printTiming) | 344 final String stepName; |
| 345 |
| 346 BuildbotProgressIndicator(Date startTime, bool printTiming, this.stepName) |
344 : super(startTime, printTiming); | 347 : super(startTime, printTiming); |
345 | 348 |
346 void _printStartProgress(TestCase test) { | 349 void _printStartProgress(TestCase test) { |
347 } | 350 } |
348 | 351 |
349 void _printDoneProgress(TestCase test) { | 352 void _printDoneProgress(TestCase test) { |
350 var status = 'pass'; | 353 var status = 'pass'; |
351 if (test.output.unexpectedOutput) { | 354 if (test.output.unexpectedOutput) { |
352 status = 'fail'; | 355 status = 'fail'; |
353 } | 356 } |
354 var percent = ((_completedTests() / _foundTests) * 100).toInt().toString(); | 357 var percent = ((_completedTests() / _foundTests) * 100).toInt().toString(); |
355 print('Done ${test.configurationString} ${test.displayName}: $status'); | 358 print('Done ${test.configurationString} ${test.displayName}: $status'); |
356 print('@@@STEP_CLEAR@@@'); | 359 print('@@@STEP_CLEAR@@@'); |
357 print('@@@STEP_TEXT@ $percent% +$_passedTests -$_failedTests @@@'); | 360 print('@@@STEP_TEXT@ $percent% +$_passedTests -$_failedTests @@@'); |
358 } | 361 } |
359 | 362 |
360 void _printFailureSummary() { | 363 void _printFailureSummary() { |
361 if (!_failureSummary.isEmpty()) { | 364 if (!_failureSummary.isEmpty()) { |
362 // We need to create a unique name for each step, otherwise, the | |
363 // build bot will show the same failure when several steps | |
364 // fail. We don't know the name of the current step as it is | |
365 // printed by the program invoking this. | |
366 // TODO(ahe): Pass in the step name as an option, and let | |
367 // test.py take care of printing the steps. | |
368 var name = 'failures ($_startTime)'; | |
369 print('@@@STEP_FAILURE@@@'); | 365 print('@@@STEP_FAILURE@@@'); |
370 print('@@@BUILD_STEP $name@@@'); | 366 print('@@@BUILD_STEP $stepName failures@@@'); |
371 } | 367 } |
372 super._printFailureSummary(); | 368 super._printFailureSummary(); |
373 } | 369 } |
374 } | 370 } |
OLD | NEW |