| OLD | NEW |
| 1 # Copyright 2012 the V8 project authors. All rights reserved. | 1 # Copyright 2012 the V8 project authors. All rights reserved. |
| 2 # Redistribution and use in source and binary forms, with or without | 2 # Redistribution and use in source and binary forms, with or without |
| 3 # modification, are permitted provided that the following conditions are | 3 # modification, are permitted provided that the following conditions are |
| 4 # met: | 4 # met: |
| 5 # | 5 # |
| 6 # * Redistributions of source code must retain the above copyright | 6 # * Redistributions of source code must retain the above copyright |
| 7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
| 8 # * Redistributions in binary form must reproduce the above | 8 # * Redistributions in binary form must reproduce the above |
| 9 # copyright notice, this list of conditions and the following | 9 # copyright notice, this list of conditions and the following |
| 10 # disclaimer in the documentation and/or other materials provided | 10 # disclaimer in the documentation and/or other materials provided |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 193 |
| 194 def Truncate(self, string, length): | 194 def Truncate(self, string, length): |
| 195 if length and (len(string) > (length - 3)): | 195 if length and (len(string) > (length - 3)): |
| 196 return string[:(length - 3)] + "..." | 196 return string[:(length - 3)] + "..." |
| 197 else: | 197 else: |
| 198 return string | 198 return string |
| 199 | 199 |
| 200 def PrintProgress(self, name): | 200 def PrintProgress(self, name): |
| 201 self.ClearLine(self.last_status_length) | 201 self.ClearLine(self.last_status_length) |
| 202 elapsed = time.time() - self.start_time | 202 elapsed = time.time() - self.start_time |
| 203 progress = 0 if not self.runner.total else ( |
| 204 ((self.runner.total - self.runner.remaining) * 100) // |
| 205 self.runner.total) |
| 203 status = self.templates['status_line'] % { | 206 status = self.templates['status_line'] % { |
| 204 'passed': self.runner.succeeded, | 207 'passed': self.runner.succeeded, |
| 205 'remaining': (((self.runner.total - self.runner.remaining) * 100) // | 208 'progress': progress, |
| 206 self.runner.total), | |
| 207 'failed': len(self.runner.failed), | 209 'failed': len(self.runner.failed), |
| 208 'test': name, | 210 'test': name, |
| 209 'mins': int(elapsed) / 60, | 211 'mins': int(elapsed) / 60, |
| 210 'secs': int(elapsed) % 60 | 212 'secs': int(elapsed) % 60 |
| 211 } | 213 } |
| 212 status = self.Truncate(status, 78) | 214 status = self.Truncate(status, 78) |
| 213 self.last_status_length = len(status) | 215 self.last_status_length = len(status) |
| 214 print status, | 216 print status, |
| 215 sys.stdout.flush() | 217 sys.stdout.flush() |
| 216 | 218 |
| 217 | 219 |
| 218 class ColorProgressIndicator(CompactProgressIndicator): | 220 class ColorProgressIndicator(CompactProgressIndicator): |
| 219 | 221 |
| 220 def __init__(self): | 222 def __init__(self): |
| 221 templates = { | 223 templates = { |
| 222 'status_line': ("[%(mins)02i:%(secs)02i|" | 224 'status_line': ("[%(mins)02i:%(secs)02i|" |
| 223 "\033[34m%%%(remaining) 4d\033[0m|" | 225 "\033[34m%%%(progress) 4d\033[0m|" |
| 224 "\033[32m+%(passed) 4d\033[0m|" | 226 "\033[32m+%(passed) 4d\033[0m|" |
| 225 "\033[31m-%(failed) 4d\033[0m]: %(test)s"), | 227 "\033[31m-%(failed) 4d\033[0m]: %(test)s"), |
| 226 'stdout': "\033[1m%s\033[0m", | 228 'stdout': "\033[1m%s\033[0m", |
| 227 'stderr': "\033[31m%s\033[0m", | 229 'stderr': "\033[31m%s\033[0m", |
| 228 } | 230 } |
| 229 super(ColorProgressIndicator, self).__init__(templates) | 231 super(ColorProgressIndicator, self).__init__(templates) |
| 230 | 232 |
| 231 def ClearLine(self, last_line_length): | 233 def ClearLine(self, last_line_length): |
| 232 print "\033[1K\r", | 234 print "\033[1K\r", |
| 233 | 235 |
| 234 | 236 |
| 235 class MonochromeProgressIndicator(CompactProgressIndicator): | 237 class MonochromeProgressIndicator(CompactProgressIndicator): |
| 236 | 238 |
| 237 def __init__(self): | 239 def __init__(self): |
| 238 templates = { | 240 templates = { |
| 239 'status_line': ("[%(mins)02i:%(secs)02i|%%%(remaining) 4d|" | 241 'status_line': ("[%(mins)02i:%(secs)02i|%%%(progress) 4d|" |
| 240 "+%(passed) 4d|-%(failed) 4d]: %(test)s"), | 242 "+%(passed) 4d|-%(failed) 4d]: %(test)s"), |
| 241 'stdout': '%s', | 243 'stdout': '%s', |
| 242 'stderr': '%s', | 244 'stderr': '%s', |
| 243 } | 245 } |
| 244 super(MonochromeProgressIndicator, self).__init__(templates) | 246 super(MonochromeProgressIndicator, self).__init__(templates) |
| 245 | 247 |
| 246 def ClearLine(self, last_line_length): | 248 def ClearLine(self, last_line_length): |
| 247 print ("\r" + (" " * last_line_length) + "\r"), | 249 print ("\r" + (" " * last_line_length) + "\r"), |
| 248 | 250 |
| 249 | 251 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 "duration": test.duration, | 364 "duration": test.duration, |
| 363 }) | 365 }) |
| 364 | 366 |
| 365 | 367 |
| 366 PROGRESS_INDICATORS = { | 368 PROGRESS_INDICATORS = { |
| 367 'verbose': VerboseProgressIndicator, | 369 'verbose': VerboseProgressIndicator, |
| 368 'dots': DotsProgressIndicator, | 370 'dots': DotsProgressIndicator, |
| 369 'color': ColorProgressIndicator, | 371 'color': ColorProgressIndicator, |
| 370 'mono': MonochromeProgressIndicator | 372 'mono': MonochromeProgressIndicator |
| 371 } | 373 } |
| OLD | NEW |