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

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

Issue 8873013: Get rid of the spinner in progress indicators. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years 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) 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 #import("test_suite.dart"); 8 #import("test_suite.dart");
9 9
10 class ProgressIndicator { 10 class ProgressIndicator {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 158
159 void allDone() { 159 void allDone() {
160 stdout.write('\n'.charCodes()); 160 stdout.write('\n'.charCodes());
161 _printTimingInformation(); 161 _printTimingInformation();
162 stdout.close(); 162 stdout.close();
163 exit(_failedTests > 0 ? 1 : 0); 163 exit(_failedTests > 0 ? 1 : 0);
164 } 164 }
165 165
166 void _printStartProgress(TestCase test) => _printProgress(); 166 void _printStartProgress(TestCase test) => _printProgress();
167 void _printDoneProgress(TestCase test) => _printProgress(); 167 void _printDoneProgress(TestCase test) => _printProgress();
168
169 String _nextSpinner() {
170 _spinnerIndex = (_spinnerIndex + 1) % 4;
171 return _spinners[_spinnerIndex];
172 }
173
174 static int _spinnerIndex = 0;
175 static List<String> _spinners = const ['- ', '\\ ', '| ', '/ '];
176 } 168 }
177 169
178 170
179 class CompactProgressIndicator extends CompactIndicator { 171 class CompactProgressIndicator extends CompactIndicator {
180 CompactProgressIndicator(Date startTime, bool printTiming) 172 CompactProgressIndicator(Date startTime, bool printTiming)
181 : super(startTime, printTiming); 173 : super(startTime, printTiming);
182 174
183 void _printProgress() { 175 void _printProgress() {
184 var percent = ((_completedTests() / _foundTests) * 100).floor().toString(); 176 var percent = ((_completedTests() / _foundTests) * 100).toInt().toString();
185 var progressPadded = _pad(_allTestsKnown ? percent : _nextSpinner(), 5); 177 var progressPadded = _pad(_allTestsKnown ? percent : '--', 3);
186 var passedPadded = _pad(_passedTests.toString(), 5); 178 var passedPadded = _pad(_passedTests.toString(), 5);
187 var failedPadded = _pad(_failedTests.toString(), 5); 179 var failedPadded = _pad(_failedTests.toString(), 5);
188 Duration d = (new Date.now()).difference(_startTime); 180 Duration d = (new Date.now()).difference(_startTime);
189 var progressLine = 181 var progressLine =
190 '\r[${_timeString(d)} | $progressPadded% | ' + 182 '\r[${_timeString(d)} | $progressPadded% | ' +
191 '+$passedPadded | -$failedPadded]'; 183 '+$passedPadded | -$failedPadded]';
192 stdout.write(progressLine.charCodes()); 184 stdout.write(progressLine.charCodes());
193 } 185 }
194 } 186 }
195 187
196 188
197 class ColorProgressIndicator extends CompactIndicator { 189 class ColorProgressIndicator extends CompactIndicator {
198 ColorProgressIndicator(Date startTime, bool printTiming) 190 ColorProgressIndicator(Date startTime, bool printTiming)
199 : super(startTime, printTiming); 191 : super(startTime, printTiming);
200 192
201 static int GREEN = 32; 193 static int GREEN = 32;
202 static int RED = 31; 194 static int RED = 31;
203 static int NONE = 0; 195 static int NONE = 0;
204 196
205 addColorWrapped(List<int> codes, String string, int color) { 197 addColorWrapped(List<int> codes, String string, int color) {
206 codes.add(27); 198 codes.add(27);
207 codes.addAll('[${color}m'.charCodes()); 199 codes.addAll('[${color}m'.charCodes());
208 codes.addAll(string.charCodes()); 200 codes.addAll(string.charCodes());
209 codes.add(27); 201 codes.add(27);
210 codes.addAll('[0m'.charCodes()); 202 codes.addAll('[0m'.charCodes());
211 } 203 }
212 204
213 void _printProgress() { 205 void _printProgress() {
214 var percent = ((_completedTests() / _foundTests) * 100).floor().toString(); 206 var percent = ((_completedTests() / _foundTests) * 100).toInt().toString();
215 var progressPadded = _pad(_allTestsKnown ? percent : _nextSpinner(), 5); 207 var progressPadded = _pad(_allTestsKnown ? percent : '--', 3);
216 var passedPadded = _pad(_passedTests.toString(), 5); 208 var passedPadded = _pad(_passedTests.toString(), 5);
217 var failedPadded = _pad(_failedTests.toString(), 5); 209 var failedPadded = _pad(_failedTests.toString(), 5);
218 Duration d = (new Date.now()).difference(_startTime); 210 Duration d = (new Date.now()).difference(_startTime);
219 var progressLine = []; 211 var progressLine = [];
220 progressLine.addAll('\r[${_timeString(d)} | $progressPadded% | '.charCodes() ); 212 progressLine.addAll('\r[${_timeString(d)} | $progressPadded% | '.charCodes() );
221 addColorWrapped(progressLine, '+$passedPadded ', GREEN); 213 addColorWrapped(progressLine, '+$passedPadded ', GREEN);
222 progressLine.addAll('| '.charCodes()); 214 progressLine.addAll('| '.charCodes());
223 var failedColor = (_failedTests != 0) ? RED : NONE; 215 var failedColor = (_failedTests != 0) ? RED : NONE;
224 addColorWrapped(progressLine, '-$failedPadded', failedColor); 216 addColorWrapped(progressLine, '-$failedPadded', failedColor);
225 progressLine.addAll(']'.charCodes()); 217 progressLine.addAll(']'.charCodes());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 var status = 'pass'; 278 var status = 'pass';
287 if (test.output.unexpectedOutput) { 279 if (test.output.unexpectedOutput) {
288 status = 'fail'; 280 status = 'fail';
289 } 281 }
290 var percent = ((_completedTests() / _foundTests) * 100).toInt().toString(); 282 var percent = ((_completedTests() / _foundTests) * 100).toInt().toString();
291 print('Done ${test.displayName}: $status'); 283 print('Done ${test.displayName}: $status');
292 print('@@@STEP_CLEAR@@@'); 284 print('@@@STEP_CLEAR@@@');
293 print('@@@STEP_TEXT@ $percent% +$_passedTests -$_failedTests @@@'); 285 print('@@@STEP_TEXT@ $percent% +$_passedTests -$_failedTests @@@');
294 } 286 }
295 } 287 }
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