1. Ned Batchelder
  2. coverage.py
  3. Pull requests

Pull requests

#13 Merged

Improve file and package names in xml output

  1. Marcus Cobden

I'm trying to improve our jenkins integration to get it showing the source code, I haven't tested this on there quite yet though.

Comments/advice appreciated :)

Comments (16)

  1. Ned Batchelder repo owner

    Marcus: can you explain why you changed name="foo" to be name="full/path/to/foo" ? In Cobertura reports, it looks right to me that name should be short. Or maybe I don't understand how this XML change will translate to a user-visible change in Jenkins?

  2. Marcus Cobden author

    This is what it looks like in our jenkins: http://imgur.com/a/aiM1T

    The first image is from the coverage report main page, the second is the report for an individual package, then the third is the individual file view, which has highlighted code output below (which I didn't screenshot).

  3. Marcus Cobden author

    I was tweaking the build, and noticed that I get completely different output when I ask nose to generate the coverage xml file versus using coverage xml to process the .coverage file.

    I think nose has a much better idea of the file __name__ (cu.name) than coverage xml does; it doesn't look like that info is recorded in the .coverage file.

  4. Michael Bayer

    I think this PR is breaking the XML output. Previously, I was able to get a <package> entry for every individual package in my code. Now I just get one anonymous <package>. PDBing, the "cu.name" attribute here doesn't have periods in it, it has slashes:

    > /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/coverage/xmlreport.py(102)xml_file()
    -> package_name = rpartition(cu.name, ".")[0]
    (Pdb) cu.name
    (Pdb) rpartition(cu.name, ".")
    ('', '', 'lib/sqlalchemy/__init__')
    (Pdb) rpartition(cu.name, ".")[0]

    Perhaps this functionality is not tested in test_xml.py ? seems like a bug to me. My coverage as you see http://jenkins.sqlalchemy.org/job/sqlalchemy-default-coverage/69/cobertura/ is just one giant <default> package.

  5. Marcus Cobden author

    Yep, I didn't expect this to get merged after I reported that it was broken! IIRC cu.name was fine when first collected, but once the data is serialized to .coverage, and re-loaded cu.name becomes cu.filename. I have no idea if this is what happens with the latest code ;)

  6. Michael Bayer

    Ned Batchelder - yeah, I've no doubt that #67 is a real bug too. I don't know the details of how this logic works but my impression is that different scenarios lead to different kinds of data being passed xmlreport.py. I'm running here with py.test and the pycov extension, so it might be calling upon Coverage in a different way than Nose does. I think the solution would involve confirming and identifying every variety of .name that can occur there, then adding logic to detect and handle each contingency explicitly.