| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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("test_runner.dart"); | 7 #import("test_runner.dart"); |
| 8 | 8 |
| 9 class ProgressIndicator { | 9 class ProgressIndicator { |
| 10 ProgressIndicator(this._startTime); | 10 ProgressIndicator(this._startTime); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 int _completedTests() => _passedTests + _failedTests; | 109 int _completedTests() => _passedTests + _failedTests; |
| 110 | 110 |
| 111 int _foundTests = 0; | 111 int _foundTests = 0; |
| 112 int _passedTests = 0; | 112 int _passedTests = 0; |
| 113 int _failedTests = 0; | 113 int _failedTests = 0; |
| 114 Date _startTime; | 114 Date _startTime; |
| 115 } | 115 } |
| 116 | 116 |
| 117 | 117 |
| 118 class CompactProgressIndicator extends ProgressIndicator { | 118 class CompactProgressIndicator extends ProgressIndicator { |
| 119 CompactProgressIndicator(Date start_time) : super(start_time); | 119 CompactProgressIndicator(Date startTime) : super(startTime); |
| 120 | 120 |
| 121 void allDone() { | 121 void allDone() { |
| 122 } | 122 } |
| 123 | 123 |
| 124 void _printProgress() { | 124 void _printProgress() { |
| 125 var percent = ((_completedTests() / _foundTests) * 100).floor().toString(); | 125 var percent = ((_completedTests() / _foundTests) * 100).floor().toString(); |
| 126 var percentPadded = _pad(percent, 5); | 126 var percentPadded = _pad(percent, 5); |
| 127 var passedPadded = _pad(_passedTests.toString(), 5); | 127 var passedPadded = _pad(_passedTests.toString(), 5); |
| 128 var failedPadded = _pad(_failedTests.toString(), 5); | 128 var failedPadded = _pad(_failedTests.toString(), 5); |
| 129 var progressLine = | 129 var progressLine = |
| 130 '\r[${_timeString()} | $percentPadded% | ' + | 130 '\r[${_timeString()} | $percentPadded% | ' + |
| 131 '+$passedPadded | -$failedPadded]'; | 131 '+$passedPadded | -$failedPadded]'; |
| 132 stdout.write(progressLine.charCodes()); | 132 stdout.write(progressLine.charCodes()); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void _printStartProgress(TestCase test) => _printProgress(); | 135 void _printStartProgress(TestCase test) => _printProgress(); |
| 136 void _printDoneProgress(TestCase test) => _printProgress(); | 136 void _printDoneProgress(TestCase test) => _printProgress(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 | 139 |
| 140 class LineProgressIndicator extends ProgressIndicator { | 140 class LineProgressIndicator extends ProgressIndicator { |
| 141 LineProgressIndicator(Date start_time) : super(start_time); | 141 LineProgressIndicator(Date startTime) : super(startTime); |
| 142 | 142 |
| 143 void allDone() { | 143 void allDone() { |
| 144 _printStatus(); | 144 _printStatus(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void _printStartProgress(TestCase test) { | 147 void _printStartProgress(TestCase test) { |
| 148 } | 148 } |
| 149 | 149 |
| 150 void _printDoneProgress(TestCase test) { | 150 void _printDoneProgress(TestCase test) { |
| 151 var status = 'pass'; | 151 var status = 'pass'; |
| 152 if (test.output.unexpectedOutput) { | 152 if (test.output.unexpectedOutput) { |
| 153 status = 'fail'; | 153 status = 'fail'; |
| 154 } | 154 } |
| 155 print('Done ${test.displayName}: $status'); | 155 print('Done ${test.displayName}: $status'); |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 | 158 |
| 159 | 159 |
| 160 class VerboseProgressIndicator extends ProgressIndicator { | 160 class VerboseProgressIndicator extends ProgressIndicator { |
| 161 VerboseProgressIndicator(Date start_time) : super(start_time); | 161 VerboseProgressIndicator(Date startTime) : super(startTime); |
| 162 | 162 |
| 163 void allDone() { | 163 void allDone() { |
| 164 _printStatus(); | 164 _printStatus(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 void _printStartProgress(TestCase test) { | 167 void _printStartProgress(TestCase test) { |
| 168 print('Starting ${test.displayName}...'); | 168 print('Starting ${test.displayName}...'); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void _printDoneProgress(TestCase test) { | 171 void _printDoneProgress(TestCase test) { |
| 172 var status = 'pass'; | 172 var status = 'pass'; |
| 173 if (test.output.unexpectedOutput) { | 173 if (test.output.unexpectedOutput) { |
| 174 status = 'fail'; | 174 status = 'fail'; |
| 175 } | 175 } |
| 176 print('Done ${test.displayName}: $status'); | 176 print('Done ${test.displayName}: $status'); |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 | 179 |
| 180 | 180 |
| 181 class StatusProgressIndicator extends ProgressIndicator { | 181 class StatusProgressIndicator extends ProgressIndicator { |
| 182 StatusProgressIndicator(Date start_time) : super(start_time); | 182 StatusProgressIndicator(Date startTime) : super(startTime); |
| 183 | 183 |
| 184 void allDone() { | 184 void allDone() { |
| 185 _printStatus(); | 185 _printStatus(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 void _printStartProgress(TestCase test) { | 188 void _printStartProgress(TestCase test) { |
| 189 } | 189 } |
| 190 | 190 |
| 191 void _printDoneProgress(TestCase test) { | 191 void _printDoneProgress(TestCase test) { |
| 192 } | 192 } |
| 193 } | 193 } |
| 194 | 194 |
| 195 | 195 |
| 196 class BuildbotProgressIndicator extends ProgressIndicator { | 196 class BuildbotProgressIndicator extends ProgressIndicator { |
| 197 BuildbotProgressIndicator(Date start_time) : super(start_time); | 197 BuildbotProgressIndicator(Date startTime) : super(startTime); |
| 198 | 198 |
| 199 void allDone() { | 199 void allDone() { |
| 200 _printStatus(); | 200 _printStatus(); |
| 201 } | 201 } |
| 202 | 202 |
| 203 void _printStartProgress(TestCase test) { | 203 void _printStartProgress(TestCase test) { |
| 204 } | 204 } |
| 205 | 205 |
| 206 void _printDoneProgress(TestCase test) { | 206 void _printDoneProgress(TestCase test) { |
| 207 var status = 'pass'; | 207 var status = 'pass'; |
| 208 if (test.output.unexpectedOutput) { | 208 if (test.output.unexpectedOutput) { |
| 209 status = 'fail'; | 209 status = 'fail'; |
| 210 } | 210 } |
| 211 var percent = ((_completedTests() / _foundTests) * 100).toInt().toString(); | 211 var percent = ((_completedTests() / _foundTests) * 100).toInt().toString(); |
| 212 print('Done ${test.displayName}: $status'); | 212 print('Done ${test.displayName}: $status'); |
| 213 print('@@@STEP_CLEAR@@@'); | 213 print('@@@STEP_CLEAR@@@'); |
| 214 print('@@@STEP_TEXT@ $percent% +$_passedTests -$_failedTests @@@'); | 214 print('@@@STEP_TEXT@ $percent% +$_passedTests -$_failedTests @@@'); |
| 215 } | 215 } |
| 216 } | 216 } |
| OLD | NEW |