Mercurial > hg
comparison tests/run-tests.py @ 27689:50e621fe0362
run-tests: skip threading for a single test
Threading is incompatible with most Python debuggers,
which makes debugging run-tests.py a real pain.
If there is only one test to run, skip using a thread for it.
Note that --debug is not compatible with debugging tests,
since it bypasses the output handling, which is where
much of the excitement is.
author | timeless <timeless@mozdev.org> |
---|---|
date | Mon, 28 Dec 2015 17:48:40 +0000 |
parents | df142b77b4c2 |
children | bf45edfa9d90 |
comparison
equal
deleted
inserted
replaced
27687:4cea1b918b21 | 27689:50e621fe0362 |
---|---|
1556 if self._showchannels: | 1556 if self._showchannels: |
1557 statthread = threading.Thread(target=stat, name="stat") | 1557 statthread = threading.Thread(target=stat, name="stat") |
1558 statthread.start() | 1558 statthread.start() |
1559 | 1559 |
1560 try: | 1560 try: |
1561 while tests or running: | 1561 if len(tests) == 1: |
1562 if not done.empty() or running == self._jobs or not tests: | 1562 test = tests.pop(0) |
1563 try: | 1563 test.run(result) |
1564 done.get(True, 1) | 1564 else: |
1565 running -= 1 | 1565 while tests or running: |
1566 if result and result.shouldStop: | 1566 if not done.empty() or running == self._jobs or not tests: |
1567 stoppedearly = True | 1567 try: |
1568 break | 1568 done.get(True, 1) |
1569 except queue.Empty: | 1569 running -= 1 |
1570 continue | 1570 if result and result.shouldStop: |
1571 if tests and not running == self._jobs: | 1571 stoppedearly = True |
1572 test = tests.pop(0) | 1572 break |
1573 if self._loop: | 1573 except queue.Empty: |
1574 if getattr(test, 'should_reload', False): | 1574 continue |
1575 num_tests[0] += 1 | 1575 if tests and not running == self._jobs: |
1576 tests.append( | 1576 test = tests.pop(0) |
1577 self._loadtest(test.name, num_tests[0])) | 1577 if self._loop: |
1578 else: | 1578 if getattr(test, 'should_reload', False): |
1579 tests.append(test) | 1579 num_tests[0] += 1 |
1580 t = threading.Thread(target=job, name=test.name, | 1580 tests.append( |
1581 args=(test, result)) | 1581 self._loadtest(test.name, num_tests[0])) |
1582 t.start() | 1582 else: |
1583 running += 1 | 1583 tests.append(test) |
1584 | 1584 t = threading.Thread(target=job, name=test.name, |
1585 # If we stop early we still need to wait on started tests to | 1585 args=(test, result)) |
1586 # finish. Otherwise, there is a race between the test completing | 1586 t.start() |
1587 # and the test's cleanup code running. This could result in the | 1587 running += 1 |
1588 # test reporting incorrect. | 1588 |
1589 if stoppedearly: | 1589 # If we stop early we still need to wait on started tests to |
1590 while running: | 1590 # finish. Otherwise, there is a race between the test completing |
1591 try: | 1591 # and the test's cleanup code running. This could result in the |
1592 done.get(True, 1) | 1592 # test reporting incorrect. |
1593 running -= 1 | 1593 if stoppedearly: |
1594 except queue.Empty: | 1594 while running: |
1595 continue | 1595 try: |
1596 done.get(True, 1) | |
1597 running -= 1 | |
1598 except queue.Empty: | |
1599 continue | |
1596 except KeyboardInterrupt: | 1600 except KeyboardInterrupt: |
1597 for test in runtests: | 1601 for test in runtests: |
1598 test.abort() | 1602 test.abort() |
1599 | 1603 |
1600 channels = [] | 1604 channels = [] |