equal
deleted
inserted
replaced
357 self._unittest = unittest |
357 self._unittest = unittest |
358 |
358 |
359 self._finished = None |
359 self._finished = None |
360 self._ret = None |
360 self._ret = None |
361 self._out = None |
361 self._out = None |
|
362 self._duration = None |
362 |
363 |
363 # If we're not in --debug mode and reference output file exists, |
364 # If we're not in --debug mode and reference output file exists, |
364 # check test output against it. |
365 # check test output against it. |
365 if runner.options.debug: |
366 if runner.options.debug: |
366 self._refout = None # to match "out is None" |
367 self._refout = None # to match "out is None" |
384 def setUp(self): |
385 def setUp(self): |
385 """Tasks to perform before run().""" |
386 """Tasks to perform before run().""" |
386 self._finished = False |
387 self._finished = False |
387 self._ret = None |
388 self._ret = None |
388 self._out = None |
389 self._out = None |
|
390 self._duration = None |
389 |
391 |
390 def run(self): |
392 def run(self): |
391 """Run this test instance. |
393 """Run this test instance. |
392 |
394 |
393 This will return a tuple describing the result of the test. |
395 This will return a tuple describing the result of the test. |
433 vlog('# Test', self.name) |
435 vlog('# Test', self.name) |
434 |
436 |
435 starttime = time.time() |
437 starttime = time.time() |
436 try: |
438 try: |
437 ret, out = self._run(testtmp, replacements, env) |
439 ret, out = self._run(testtmp, replacements, env) |
438 duration = time.time() - starttime |
440 self._duration = time.time() - starttime |
439 self._finished = True |
441 self._finished = True |
440 self._ret = ret |
442 self._ret = ret |
441 self._out = out |
443 self._out = out |
442 except KeyboardInterrupt: |
444 except KeyboardInterrupt: |
443 duration = time.time() - starttime |
445 self._duration = time.time() - starttime |
444 log('INTERRUPTED: %s (after %d seconds)' % (self.name, duration)) |
446 log('INTERRUPTED: %s (after %d seconds)' % (self.name, |
|
447 self._duration)) |
445 raise |
448 raise |
446 except Exception, e: |
449 except Exception, e: |
447 return self.fail('Exception during execution: %s' % e, 255) |
450 return self.fail('Exception during execution: %s' % e, 255) |
448 |
451 |
449 killdaemons(env['DAEMON_PIDS']) |
452 killdaemons(env['DAEMON_PIDS']) |
516 iolock.acquire() |
519 iolock.acquire() |
517 sys.stdout.write(res[0]) |
520 sys.stdout.write(res[0]) |
518 sys.stdout.flush() |
521 sys.stdout.flush() |
519 iolock.release() |
522 iolock.release() |
520 |
523 |
521 self._runner.times.append((self.name, duration)) |
524 if not self._unittest: |
|
525 self.tearDown() |
522 |
526 |
523 return res |
527 return res |
524 |
528 |
525 def tearDown(self): |
529 def tearDown(self): |
526 """Tasks to perform after run().""" |
530 """Tasks to perform after run().""" |
|
531 self._runner.times.append((self.name, self._duration)) |
527 |
532 |
528 def _run(self, testtmp, replacements, env): |
533 def _run(self, testtmp, replacements, env): |
529 # This should be implemented in child classes to run tests. |
534 # This should be implemented in child classes to run tests. |
530 return self._skip('unknown test type') |
535 return self._skip('unknown test type') |
531 |
536 |