[TIP] tox and coverage across multiple envs

Geoff Bache geoff.bache at gmail.com
Wed Aug 10 04:55:27 PDT 2011


See also https://bitbucket.org/ned/coveragepy/issue/17. I've thought
for a while that there should be a way to tell "coverage combine" that
various root directories should be considered as equivalent to one
another. Another common usage of this is to combine data from e.g.
Linux and Windows.

Regards,
Geoff

On Wed, Aug 10, 2011 at 11:33 AM, meme dough <memedough at gmail.com> wrote:
> Hi,
>
> The coverage data file stores the paths and they are different for the
> various tox environments.
>
> Before you combine them with coverage you need to rewrite the paths so
> that they appear to be in the same location.  Then tell coverage to
> combine them.
>
> You could easily write a small script to load each coverage data file
> using the coverage api, see
>
> https://bitbucket.org/ned/coveragepy/src/56a85a983eb7/coverage/control.py
>
> Give it the name of the data file to load, load it, rewrite the
> filenames in the data.lines and data.arcs and save it out.  For an
> example see (right down the bottom)
>
> https://bitbucket.org/memedough/cov-core/src/b9a3c9756366/cov_core.py
>
> Then do the normal combine and the paths will match to combine the results.
>
> :)
>
> On 10 August 2011 17:42, Andrew Dalke <dalke at dalkescientific.com> wrote:
>> Hi Ned,
>>
>> On Aug 10, 2011, at 2:32 AM, Ned Batchelder wrote:
>>> I don't understand what those file names are that you're showing.
>>> You should have gotten data files like .coverage.machine.pid.12345 .
>>> And then "coverage combine" should have created a single .coverage
>>> file from them.  I'm not familiar with tox, is there something it
>>> does to affect the coverage collection?
>>
>> Each tox environment has a name, like "py27-oe174" or "py27-ob23svn1",
>> and an associated configuration. Each configuration may have
>> dependencies. Tox makes a virtualenv for py27-oe174 under the
>> directory (this includes any extra download/installs)
>>
>>  ./tox/py27-oe174
>>
>> To run an environment, it appears that tox does a "setup.py install"
>> into the associated directory. For this environment the module
>> is put into
>>
>>  .tox/py27-oe174/lib/python2.7/site-packages/chemfp
>>
>> but for another environment it's put into
>>
>>  .tox/py27-ob23svn1/lib/python2.7/site-packages/chemfp/
>>
>>
>> Then because of the tox "commands" setting of
>>  coverage run -p ./tests/unit2 discover -s tests
>>
>> tox runs the environment specific "coverage".
>>
>> This puts the various .coverage.machine.pid.12345 files into
>> my top-level directory, which I can collect.
>>
>> The problem is that each tox environment has its own PYTHONPATH,
>> so that "from chemfp import openbabel" refers to
>>
>>  .tox/py27-oe174/lib/python2.7/site-packages/chemfp/openbabel.py
>> -or-
>>  .tox/py27-ob23svn1/lib/python2.7/site-packages/chemfp/openbabel.py
>> -or-
>>  ...
>>
>> depending on the environment that I run. This is how tox
>> maintains the needed isolation.
>>
>> The problem is that I want to merge those different reports
>> into one. In my case I can get what I want by removing
>>
>>  .tox/.*/site-packages/
>>
>> though I don't know if that's a generally useful practice.
>>
>> Perhaps there's an easy way to hack the .coverage.* format?
>>
>>                                Andrew
>>                                dalke at dalkescientific.com
>>
>>
>>
>> _______________________________________________
>> testing-in-python mailing list
>> testing-in-python at lists.idyll.org
>> http://lists.idyll.org/listinfo/testing-in-python
>>
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
>



More information about the testing-in-python mailing list