Mercurial > public > mercurial-scm > hg
comparison tests/run-tests.py @ 27880:b04df9ce1fb0
run-tests: skip threading for a single test (issue5040)
This version backs out 50e621fe0362 and implements it in
a more consistent manner.
author | timeless <timeless@mozdev.org> |
---|---|
date | Thu, 14 Jan 2016 04:14:50 +0000 |
parents | 47ac135113ec |
children | 4c6053a6b17d |
comparison
equal
deleted
inserted
replaced
27879:52a4ad62b006 | 27880:b04df9ce1fb0 |
---|---|
1440 | 1440 |
1441 jobs specifies the number of jobs to run concurrently. Each test | 1441 jobs specifies the number of jobs to run concurrently. Each test |
1442 executes on its own thread. Tests actually spawn new processes, so | 1442 executes on its own thread. Tests actually spawn new processes, so |
1443 state mutation should not be an issue. | 1443 state mutation should not be an issue. |
1444 | 1444 |
1445 If there is only one job, it will use the main thread. | |
1446 | |
1445 whitelist and blacklist denote tests that have been whitelisted and | 1447 whitelist and blacklist denote tests that have been whitelisted and |
1446 blacklisted, respectively. These arguments don't belong in TestSuite. | 1448 blacklisted, respectively. These arguments don't belong in TestSuite. |
1447 Instead, whitelist and blacklist should be handled by the thing that | 1449 Instead, whitelist and blacklist should be handled by the thing that |
1448 populates the TestSuite with tests. They are present to preserve | 1450 populates the TestSuite with tests. They are present to preserve |
1449 backwards compatible behavior which reports skipped tests as part | 1451 backwards compatible behavior which reports skipped tests as part |
1556 if self._showchannels: | 1558 if self._showchannels: |
1557 statthread = threading.Thread(target=stat, name="stat") | 1559 statthread = threading.Thread(target=stat, name="stat") |
1558 statthread.start() | 1560 statthread.start() |
1559 | 1561 |
1560 try: | 1562 try: |
1561 if len(tests) == 1: | 1563 while tests or running: |
1562 test = tests.pop(0) | 1564 if not done.empty() or running == self._jobs or not tests: |
1563 test.run(result) | 1565 try: |
1564 else: | 1566 done.get(True, 1) |
1565 while tests or running: | 1567 running -= 1 |
1566 if not done.empty() or running == self._jobs or not tests: | 1568 if result and result.shouldStop: |
1567 try: | 1569 stoppedearly = True |
1568 done.get(True, 1) | 1570 break |
1569 running -= 1 | 1571 except queue.Empty: |
1570 if result and result.shouldStop: | 1572 continue |
1571 stoppedearly = True | 1573 if tests and not running == self._jobs: |
1572 break | 1574 test = tests.pop(0) |
1573 except queue.Empty: | 1575 if self._loop: |
1574 continue | 1576 if getattr(test, 'should_reload', False): |
1575 if tests and not running == self._jobs: | 1577 num_tests[0] += 1 |
1576 test = tests.pop(0) | 1578 tests.append( |
1577 if self._loop: | 1579 self._loadtest(test.name, num_tests[0])) |
1578 if getattr(test, 'should_reload', False): | 1580 else: |
1579 num_tests[0] += 1 | 1581 tests.append(test) |
1580 tests.append( | 1582 if self._jobs == 1: |
1581 self._loadtest(test.name, num_tests[0])) | 1583 job(test, result) |
1582 else: | 1584 else: |
1583 tests.append(test) | |
1584 t = threading.Thread(target=job, name=test.name, | 1585 t = threading.Thread(target=job, name=test.name, |
1585 args=(test, result)) | 1586 args=(test, result)) |
1586 t.start() | 1587 t.start() |
1587 running += 1 | 1588 running += 1 |
1588 | 1589 |
1589 # If we stop early we still need to wait on started tests to | 1590 # If we stop early we still need to wait on started tests to |
1590 # finish. Otherwise, there is a race between the test completing | 1591 # finish. Otherwise, there is a race between the test completing |
1591 # and the test's cleanup code running. This could result in the | 1592 # and the test's cleanup code running. This could result in the |
1592 # test reporting incorrect. | 1593 # test reporting incorrect. |
1593 if stoppedearly: | 1594 if stoppedearly: |
1594 while running: | 1595 while running: |
1595 try: | 1596 try: |
1596 done.get(True, 1) | 1597 done.get(True, 1) |
1597 running -= 1 | 1598 running -= 1 |
1598 except queue.Empty: | 1599 except queue.Empty: |
1599 continue | 1600 continue |
1600 except KeyboardInterrupt: | 1601 except KeyboardInterrupt: |
1601 for test in runtests: | 1602 for test in runtests: |
1602 test.abort() | 1603 test.abort() |
1603 | 1604 |
1604 channels = [] | 1605 channels = [] |