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

Side by Side Diff: tools/test.py

Issue 6871007: Reapply 7581, Fix tools/test.py to allow CTRL+C to work correctly again. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 8 months 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 | « test/sputnik/testcfg.py ('k') | 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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2008 the V8 project authors. All rights reserved. 3 # Copyright 2008 the V8 project authors. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 except Empty: 110 except Empty:
111 return 111 return
112 case = test.case 112 case = test.case
113 self.lock.acquire() 113 self.lock.acquire()
114 self.AboutToRun(case) 114 self.AboutToRun(case)
115 self.lock.release() 115 self.lock.release()
116 try: 116 try:
117 start = time.time() 117 start = time.time()
118 output = case.Run() 118 output = case.Run()
119 case.duration = (time.time() - start) 119 case.duration = (time.time() - start)
120 except BreakNowException:
121 self.terminate = True
120 except IOError, e: 122 except IOError, e:
121 assert self.terminate 123 assert self.terminate
122 return 124 return
123 if self.terminate: 125 if self.terminate:
124 return 126 return
125 self.lock.acquire() 127 self.lock.acquire()
126 if output.UnexpectedOutput(): 128 if output.UnexpectedOutput():
127 self.failed.append(output) 129 self.failed.append(output)
128 if output.HasCrashed(): 130 if output.HasCrashed():
129 self.crashed += 1 131 self.crashed += 1
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 'dots': DotsProgressIndicator, 313 'dots': DotsProgressIndicator,
312 'color': ColorProgressIndicator, 314 'color': ColorProgressIndicator,
313 'mono': MonochromeProgressIndicator 315 'mono': MonochromeProgressIndicator
314 } 316 }
315 317
316 318
317 # ------------------------- 319 # -------------------------
318 # --- F r a m e w o r k --- 320 # --- F r a m e w o r k ---
319 # ------------------------- 321 # -------------------------
320 322
323 class BreakNowException(Exception):
324 def __init__(self, value):
325 self.value = value
326 def __str__(self):
327 return repr(self.value)
328
321 329
322 class CommandOutput(object): 330 class CommandOutput(object):
323 331
324 def __init__(self, exit_code, timed_out, stdout, stderr): 332 def __init__(self, exit_code, timed_out, stdout, stderr):
325 self.exit_code = exit_code 333 self.exit_code = exit_code
326 self.timed_out = timed_out 334 self.timed_out = timed_out
327 self.stdout = stdout 335 self.stdout = stdout
328 self.stderr = stderr 336 self.stderr = stderr
329 self.failed = None 337 self.failed = None
330 338
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 pass 380 pass
373 381
374 def AfterRun(self, result): 382 def AfterRun(self, result):
375 pass 383 pass
376 384
377 def GetCustomFlags(self, mode): 385 def GetCustomFlags(self, mode):
378 return None 386 return None
379 387
380 def Run(self): 388 def Run(self):
381 self.BeforeRun() 389 self.BeforeRun()
382 result = "exception" 390 result = None
383 try: 391 try:
384 result = self.RunCommand(self.GetCommand()) 392 result = self.RunCommand(self.GetCommand())
393 except:
394 self.terminate = True
395 raise BreakNowException("Used pressed CTRL+C or IO went wrong")
385 finally: 396 finally:
386 self.AfterRun(result) 397 self.AfterRun(result)
387 return result 398 return result
388 399
389 def Cleanup(self): 400 def Cleanup(self):
390 return 401 return
391 402
392 403
393 class TestOutput(object): 404 class TestOutput(object):
394 405
(...skipping 21 matching lines...) Expand all
416 if utils.IsWindows(): 427 if utils.IsWindows():
417 return 0x80000000 & self.output.exit_code and not (0x3FFFFF00 & self.outpu t.exit_code) 428 return 0x80000000 & self.output.exit_code and not (0x3FFFFF00 & self.outpu t.exit_code)
418 else: 429 else:
419 # Timed out tests will have exit_code -signal.SIGTERM. 430 # Timed out tests will have exit_code -signal.SIGTERM.
420 if self.output.timed_out: 431 if self.output.timed_out:
421 return False 432 return False
422 return self.output.exit_code < 0 and \ 433 return self.output.exit_code < 0 and \
423 self.output.exit_code != -signal.SIGABRT 434 self.output.exit_code != -signal.SIGABRT
424 435
425 def HasTimedOut(self): 436 def HasTimedOut(self):
426 return self.output.timed_out; 437 return self.output.timed_out
427 438
428 def HasFailed(self): 439 def HasFailed(self):
429 execution_failed = self.test.DidFail(self.output) 440 execution_failed = self.test.DidFail(self.output)
430 if self.test.IsNegative(): 441 if self.test.IsNegative():
431 return not execution_failed 442 return not execution_failed
432 else: 443 else:
433 return execution_failed 444 return execution_failed
434 445
435 446
436 def KillProcessWithID(pid): 447 def KillProcessWithID(pid):
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 706
696 def GetTimeout(self, testcase, mode): 707 def GetTimeout(self, testcase, mode):
697 result = self.timeout * TIMEOUT_SCALEFACTOR[mode] 708 result = self.timeout * TIMEOUT_SCALEFACTOR[mode]
698 if '--stress-opt' in self.GetVmFlags(testcase, mode): 709 if '--stress-opt' in self.GetVmFlags(testcase, mode):
699 return result * 2 710 return result * 2
700 else: 711 else:
701 return result 712 return result
702 713
703 def RunTestCases(cases_to_run, progress, tasks): 714 def RunTestCases(cases_to_run, progress, tasks):
704 progress = PROGRESS_INDICATORS[progress](cases_to_run) 715 progress = PROGRESS_INDICATORS[progress](cases_to_run)
705 return progress.Run(tasks) 716 result = 0
717 try:
718 result = progress.Run(tasks)
719 except Exception, e:
720 print "\n", e
721 return result
706 722
707 723
708 def BuildRequirements(context, requirements, mode, scons_flags): 724 def BuildRequirements(context, requirements, mode, scons_flags):
709 command_line = (['scons', '-Y', context.workspace, 'mode=' + ",".join(mode)] 725 command_line = (['scons', '-Y', context.workspace, 'mode=' + ",".join(mode)]
710 + requirements 726 + requirements
711 + scons_flags) 727 + scons_flags)
712 output = ExecuteNoCapture(command_line, context) 728 output = ExecuteNoCapture(command_line, context)
713 return output.exit_code == 0 729 return output.exit_code == 0
714 730
715 731
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 millis = round(d * 1000) % 1000 1348 millis = round(d * 1000) % 1000
1333 return time.strftime("%M:%S.", time.gmtime(d)) + ("%03i" % millis) 1349 return time.strftime("%M:%S.", time.gmtime(d)) + ("%03i" % millis)
1334 1350
1335 def ShardTests(tests, options): 1351 def ShardTests(tests, options):
1336 if options.shard_count < 2: 1352 if options.shard_count < 2:
1337 return tests 1353 return tests
1338 if options.shard_run < 1 or options.shard_run > options.shard_count: 1354 if options.shard_run < 1 or options.shard_run > options.shard_count:
1339 print "shard-run not a valid number, should be in [1:shard-count]" 1355 print "shard-run not a valid number, should be in [1:shard-count]"
1340 print "defaulting back to running all tests" 1356 print "defaulting back to running all tests"
1341 return tests 1357 return tests
1342 count = 0; 1358 count = 0
1343 shard = [] 1359 shard = []
1344 for test in tests: 1360 for test in tests:
1345 if count % options.shard_count == options.shard_run - 1: 1361 if count % options.shard_count == options.shard_run - 1:
1346 shard.append(test); 1362 shard.append(test)
1347 count += 1 1363 count += 1
1348 return shard 1364 return shard
1349 1365
1350 def Main(): 1366 def Main():
1351 parser = BuildOptions() 1367 parser = BuildOptions()
1352 (options, args) = parser.parse_args() 1368 (options, args) = parser.parse_args()
1353 if not ProcessOptions(options): 1369 if not ProcessOptions(options):
1354 parser.print_help() 1370 parser.print_help()
1355 return 1 1371 return 1
1356 1372
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1481 for entry in timed_tests[:20]: 1497 for entry in timed_tests[:20]:
1482 t = FormatTime(entry.duration) 1498 t = FormatTime(entry.duration)
1483 sys.stderr.write("%4i (%s) %s\n" % (index, t, entry.GetLabel())) 1499 sys.stderr.write("%4i (%s) %s\n" % (index, t, entry.GetLabel()))
1484 index += 1 1500 index += 1
1485 1501
1486 return result 1502 return result
1487 1503
1488 1504
1489 if __name__ == '__main__': 1505 if __name__ == '__main__':
1490 sys.exit(Main()) 1506 sys.exit(Main())
OLDNEW
« no previous file with comments | « test/sputnik/testcfg.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698