Mercurial > hg
comparison tests/run-tests.py @ 21320:e5eed8ded168
run-tests: handle interrupted in Test.run()
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 19 Apr 2014 20:27:18 -0700 |
parents | 44c96e2bab20 |
children | d06b09dc80a5 |
comparison
equal
deleted
inserted
replaced
21319:44c96e2bab20 | 21320:e5eed8ded168 |
---|---|
549 | 549 |
550 Test instances can be run multiple times via run(). However, multiple | 550 Test instances can be run multiple times via run(). However, multiple |
551 runs cannot be run concurrently. | 551 runs cannot be run concurrently. |
552 """ | 552 """ |
553 | 553 |
554 def __init__(self, path, options, count, refpath): | 554 def __init__(self, test, path, options, count, refpath): |
555 self._test = test | |
555 self._path = path | 556 self._path = path |
556 self._options = options | 557 self._options = options |
557 self._count = count | 558 self._count = count |
558 self._daemonpids = [] | 559 self._daemonpids = [] |
559 | 560 |
596 updateduration() | 597 updateduration() |
597 result.ret = ret | 598 result.ret = ret |
598 result.out = out | 599 result.out = out |
599 except KeyboardInterrupt: | 600 except KeyboardInterrupt: |
600 updateduration() | 601 updateduration() |
601 result.interrupted = True | 602 log('INTERRUPTED: %s (after %d seconds)' % (self._test, |
603 result.duration)) | |
604 raise | |
602 except Exception, e: | 605 except Exception, e: |
603 updateduration() | 606 updateduration() |
604 result.exception = e | 607 result.exception = e |
605 | 608 |
606 killdaemons(env['DAEMON_PIDS']) | 609 killdaemons(env['DAEMON_PIDS']) |
671 | 674 |
672 def __init__(self): | 675 def __init__(self): |
673 self.ret = None | 676 self.ret = None |
674 self.out = None | 677 self.out = None |
675 self.duration = None | 678 self.duration = None |
676 self.interrupted = False | |
677 self.exception = None | 679 self.exception = None |
678 self.refout = None | 680 self.refout = None |
679 | 681 |
680 @property | 682 @property |
681 def skipped(self): | 683 def skipped(self): |
1089 vlog("# Test", test) | 1091 vlog("# Test", test) |
1090 | 1092 |
1091 if os.path.exists(err): | 1093 if os.path.exists(err): |
1092 os.remove(err) # Remove any previous output files | 1094 os.remove(err) # Remove any previous output files |
1093 | 1095 |
1094 t = runner(testpath, options, count, ref) | 1096 t = runner(test, testpath, options, count, ref) |
1095 res = TestResult() | 1097 res = TestResult() |
1096 t.run(res) | 1098 t.run(res) |
1097 t.cleanup() | 1099 t.cleanup() |
1098 | |
1099 if res.interrupted: | |
1100 log('INTERRUPTED: %s (after %d seconds)' % (test, res.duration)) | |
1101 raise KeyboardInterrupt() | |
1102 | 1100 |
1103 if res.exception: | 1101 if res.exception: |
1104 return fail('Exception during execution: %s' % res.exception, 255) | 1102 return fail('Exception during execution: %s' % res.exception, 255) |
1105 | 1103 |
1106 ret = res.ret | 1104 ret = res.ret |