eriwen / lcov-to-cobertura-xml

Converts lcov output to Cobertura-compatible XML for CI
https://eriwen.github.io/lcov-to-cobertura-xml/
Apache License 2.0
187 stars 73 forks source link

Patch 1 #29

Open doyou89 opened 6 years ago

doyou89 commented 6 years ago

xml.dom use too much memory, so converting big lcov file may result in memory error on memory limitated environment like jenkins. xml.etree will reduce memory usage to under 10~20% than xml.dom. But xml.etree not support prettyxml, so if you want to generate pretty xml, use xmllint.

doyou89 commented 3 years ago

If this is useless, let me know.

sarnold commented 2 years ago

I was also having issues with a large sample file (~128 MBs or so) which makes me want to test this...

sarnold commented 2 years ago

I rebased on master but now the diff tests are failing:

$ tox -e py39-linux
py39-linux create: /home/nerdboy/src/lcov-to-cobertura-xml.work/.tox/py39-linux
py39-linux installdeps: pip>=20.3, -e.[test,cov]
py39-linux installed: attrs==21.4.0,coverage==6.3.2,iniconfig==1.1.1,-e git+ssh://git@github.com/sarnold/lcov-to-cobertura-xml.git@39d9a61e2ffc6d1101dd9a3df363e2f14f7daed0#egg=lcov_cobertura,lxml==4.8.0,packaging==21.3,pluggy==1.0.0,py==1.11.0,pyparsing==3.0.7,pytest==7.1.1,pytest-cov==3.0.0,six==1.16.0,tomli==2.0.1,xmldiff==2.4
py39-linux run-test-pre: PYTHONHASHSEED='2106106915'
py39-linux run-test: commands[0] | pytest -v . --capture=no --doctest-modules --cov lcov_cobertura --cov-branch --cov-report term-missing
============================= test session starts ==============================
platform linux -- Python 3.9.7, pytest-7.1.1, pluggy-1.0.0 -- /home/nerdboy/src/lcov-to-cobertura-xml.work/.tox/py39-linux/bin/python
cachedir: .tox/py39-linux/.pytest_cache
rootdir: /home/nerdboy/src/lcov-to-cobertura-xml.work, configfile: pyproject.toml
plugins: cov-3.0.0
collected 8 items                                                              

lcov_cobertura/lcov_cobertura.py::lcov_cobertura.LcovCobertura FAILED
test/test_lcov_cobertura.py::Test::test_demangle PASSED
test/test_lcov_cobertura.py::Test::test_exclude_package_from_parser PASSED
test/test_lcov_cobertura.py::Test::test_generate_cobertura_xml FAILED
test/test_lcov_cobertura.py::Test::test_parse PASSED
test/test_lcov_cobertura.py::Test::test_parse_with_functions PASSED
test/test_lcov_cobertura.py::Test::test_support_function_names_with_commas PASSED
test/test_lcov_cobertura.py::Test::test_treat_non_integer_line_execution_count_as_zero PASSED

@doyou89 Please rebase your branch against master and try again? The tools are a bit nicer now; just install tox and run tox -e py. I didn't try my test file yet, but LLVM source coverage seems to contain 4 different metrics, namely Branch, Line, Function, and Region coverage. It does work with a small-ish LLVM lcov file, just not the big one.

sarnold commented 2 years ago

Well, it does work on the large file, and the coverage.xml file is 248MB:

$ time tox -e big
big installed: lcov-cobertura==2.0.1
big run-test-pre: PYTHONHASHSEED='4002387385'
big runtests: commands[0] | lcov_cobertura test/lcov.info --output coverage.xml
___________________________________ summary ____________________________________
  big: commands succeeded
  congratulations :)

real    5m45.614s
user    5m39.118s
sys     0m6.074s
doyou89 commented 2 years ago

@sarnold thank you for check. Conflicts resolved, merge plz.

doyou89 commented 2 years ago

@sarnold I had rebased my branch. merge plz.