Mercurial > hg
annotate tests/sitecustomize.py @ 33766:4c706037adef
wireproto: overhaul iterating batcher code (API)
The remote batching code is difficult to read. Let's improve it.
As part of the refactor, the future returned by method calls on
batchiter() instances is now populated. However, you still need to
consume the results() generator for the future to be set. But at
least now we can stuff the future somewhere and not have to worry
about aligning method call order with result order since you can
use a future to hold the result.
Also as part of the change, we now verify that @batchable generators
yield exactly 2 values. In other words, we enforce their API.
The non-iter batcher has been unused since b6e71f8af5b8. And to my
surprise we had no explicit unit test coverage of it! test-batching.py
has been overhauled to use the iterating batcher.
Since the iterating batcher doesn't allow non-batchable method
calls nor local calls, tests have been updated to reflect reality.
The iterating batcher has been used for multiple releases apparently
without major issue. So this shouldn't cause alarm.
.. api::
@peer.batchable functions must now yield exactly 2 values
Differential Revision: https://phab.mercurial-scm.org/D319
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 09 Aug 2017 23:29:30 -0700 |
parents | d2c40510104e |
children | 2372284d9457 |
rev | line source |
---|---|
28946
b12bda49c3e3
py3: use absolute_import in sitecustomize.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
24505
diff
changeset
|
1 from __future__ import absolute_import |
24505
031947baf4d0
run-tests: collect aggregate code coverage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
14971
diff
changeset
|
2 import os |
031947baf4d0
run-tests: collect aggregate code coverage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
14971
diff
changeset
|
3 |
031947baf4d0
run-tests: collect aggregate code coverage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
14971
diff
changeset
|
4 if os.environ.get('COVERAGE_PROCESS_START'): |
031947baf4d0
run-tests: collect aggregate code coverage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
14971
diff
changeset
|
5 try: |
031947baf4d0
run-tests: collect aggregate code coverage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
14971
diff
changeset
|
6 import coverage |
30477
d2c40510104e
tests: update sitecustomize to use uuid1() instead of randrange()
Augie Fackler <augie@google.com>
parents:
28946
diff
changeset
|
7 import uuid |
24505
031947baf4d0
run-tests: collect aggregate code coverage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
14971
diff
changeset
|
8 |
031947baf4d0
run-tests: collect aggregate code coverage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
14971
diff
changeset
|
9 covpath = os.path.join(os.environ['COVERAGE_DIR'], |
30477
d2c40510104e
tests: update sitecustomize to use uuid1() instead of randrange()
Augie Fackler <augie@google.com>
parents:
28946
diff
changeset
|
10 'cov.%s' % uuid.uuid1()) |
24505
031947baf4d0
run-tests: collect aggregate code coverage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
14971
diff
changeset
|
11 cov = coverage.coverage(data_file=covpath, auto_data=True) |
031947baf4d0
run-tests: collect aggregate code coverage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
14971
diff
changeset
|
12 cov._warn_no_data = False |
031947baf4d0
run-tests: collect aggregate code coverage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
14971
diff
changeset
|
13 cov._warn_unimported_source = False |
031947baf4d0
run-tests: collect aggregate code coverage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
14971
diff
changeset
|
14 cov.start() |
031947baf4d0
run-tests: collect aggregate code coverage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
14971
diff
changeset
|
15 except ImportError: |
031947baf4d0
run-tests: collect aggregate code coverage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
14971
diff
changeset
|
16 pass |