Mercurial > hg > mercurial-source
comparison tests/run-tests.py @ 21438:f647287b44d1
run-tests: pass an optional TestResult into _executetests()
If the result is passed, we execute tests in the unittest way. A
subsequent patch will actually do this.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 20 Apr 2014 13:00:40 -0700 |
parents | d9532be2fc4d |
children | 2e22954b97e3 |
comparison
equal
deleted
inserted
replaced
21437:d9532be2fc4d | 21438:f647287b44d1 |
---|---|
1074 '.': [], | 1074 '.': [], |
1075 '!': [], | 1075 '!': [], |
1076 '~': [], | 1076 '~': [], |
1077 's': [], | 1077 's': [], |
1078 'i': [], | 1078 'i': [], |
1079 'u': [], | |
1079 } | 1080 } |
1080 self.abort = [False] | 1081 self.abort = [False] |
1081 self._createdfiles = [] | 1082 self._createdfiles = [] |
1082 self._hgpath = None | 1083 self._hgpath = None |
1083 | 1084 |
1532 adir = os.path.join(self.testdir, 'annotated') | 1533 adir = os.path.join(self.testdir, 'annotated') |
1533 if not os.path.isdir(adir): | 1534 if not os.path.isdir(adir): |
1534 os.mkdir(adir) | 1535 os.mkdir(adir) |
1535 covrun('-i', '-a', '"--directory=%s"' % adir, '"--omit=%s"' % omit) | 1536 covrun('-i', '-a', '"--directory=%s"' % adir, '"--omit=%s"' % omit) |
1536 | 1537 |
1537 def _executetests(self, tests): | 1538 def _executetests(self, tests, result=None): |
1539 # We copy because we modify the list. | |
1540 tests = list(tests) | |
1541 | |
1538 jobs = self.options.jobs | 1542 jobs = self.options.jobs |
1539 done = queue.Queue() | 1543 done = queue.Queue() |
1540 running = 0 | 1544 running = 0 |
1541 | 1545 |
1542 def job(test): | 1546 def job(test, result): |
1543 try: | 1547 try: |
1544 done.put(test.run()) | 1548 # If in unittest mode. |
1549 if result: | |
1550 test(result) | |
1551 # We need to put something here to make the logic happy. | |
1552 # This will get cleaned up later. | |
1553 done.put(('u', None, None)) | |
1554 else: | |
1555 done.put(test.run()) | |
1545 test.cleanup() | 1556 test.cleanup() |
1546 except KeyboardInterrupt: | 1557 except KeyboardInterrupt: |
1547 pass | 1558 pass |
1548 except: # re-raises | 1559 except: # re-raises |
1549 done.put(('!', test, 'run-test raised an error, see traceback')) | 1560 done.put(('!', test, 'run-test raised an error, see traceback')) |
1563 if tests and not running == jobs: | 1574 if tests and not running == jobs: |
1564 test = tests.pop(0) | 1575 test = tests.pop(0) |
1565 if self.options.loop: | 1576 if self.options.loop: |
1566 tests.append(test) | 1577 tests.append(test) |
1567 t = threading.Thread(target=job, name=test.name, | 1578 t = threading.Thread(target=job, name=test.name, |
1568 args=[test]) | 1579 args=(test, result)) |
1569 t.start() | 1580 t.start() |
1570 running += 1 | 1581 running += 1 |
1571 except KeyboardInterrupt: | 1582 except KeyboardInterrupt: |
1572 self.abort[0] = True | 1583 self.abort[0] = True |
1573 | 1584 |