My build environment is configured to compile, run and create coverage file at the command line (using Ned Batchelder coverage.py tool).
I'm using Eclipse with PyDev as my editor, but for practical reasons, it's not possible/convenient for me to convert my whole build environment to Eclipse (and thus generate the coverage data directly from the IDE, as it's designed to do)
PyDev seems to be using the same coverage tool (or something very similar to it) to generate its coverage information, so I'm guessing there should be some way of integrating my external coverage files into Eclipse/PyDev.
Any idea on how to do this?
-
I don't know anything about PyDev's integration of coverage.py (or if it even uses coverage.py), but the .coverage files are pretty simple. They are marhsal'ed dictionaries.
I haven't tested this code, but you can try this to combine two .coverage files into one:
import marshal c1_dict = marshal.load(open(file_name_1, 'rb')) c2_dict = marshal.load(open(file_name_2, 'rb')) c1_dict.update(c2_dict) marshal.dump(c1_dict, open(file_name_out, 'wb'))Kena : Thanks... I guess I'm going to dive into PyDev's code then.Kena : I wish I could set both of you and DzinX's answers as accepted, since your insight into .coverage files was helpful in solving part of my problem. His is a more direct answer of my question, so he'll get the rep, but you'd desserve it too. -
I needed exactly something like this some time ago, when PyDev still used an older version of
coverage.pythan the one accessible from the script creator's page.What I did was detecting where PyDev was saving his
.coveragefile. For me it was:C:\Users\Admin\workspace\.metadata\.plugins\org.python.pydev.debug\.coverageThen I manually ran a new version of
coverage.pyfrom a separate script and told it to save its .coverage file in the place where PyDev saves its. I cannot remember if there is a command-line argument tocoverage.pyor if I simply copied the.coveragefile with a script, but after that, if you simply open the Code Coverage Results View and click Refresh coverage information!, PyDev will nicely process the data as if it generated the file itself.Kena : Thanks, that seems to work for at least the trivial case.DzinX : For me, it worked for a really large (20+ KLOC) project with lots of test suites.Kena : I confirm that this indeed works for my project
0 comments:
Post a Comment