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

Index Out Of bounds #12

Closed StuClift closed 9 years ago

StuClift commented 11 years ago

lcov: LCOV version 1.10 Running the script:

Traceback (most recent call last):
  File "lcov_cobertura.py", line 359, in <module>
    main(sys.argv)
  File "lcov_cobertura.py", line 353, in main
    cobertura_xml = lcov_cobertura.convert()
  File "lcov_cobertura.py", line 55, in convert
    coverage_data = self.parse()
  File "lcov_cobertura.py", line 162, in parse
    function_name = line_parts[-1].strip().split(',')[1]
IndexError: list index out of range

genhtml creates correct html from the coverage.info

nyue commented 11 years ago

I am also encountering this problem.

Looking at the python code and my case, I believe it has to do with the fact that if function_name is not a simple/single word and contains spaces, ::, << >> etc (in the case of templatize code, the dictionary will fail to find the item.

I am using 1.4

rankers commented 9 years ago

Yep exactly the same from me, I'm on verison 1.4. I'm trying to use this on some objective-c code.

Function names can take the form FN:36,-[className methodName: someMoreStuff:] so when you make the line_parts array by splitting on ":" it actually splits the function name into bits.

When you come round to setting the function name variable you pick the last item in the line_parts array to work on but it can be just "]".

Maybe a work around could be splitting on ":" to initially get the input_type but then rejoining all but the first element back up to get an array of line parts as if there was only ever one colon on the line

Something like:

line_parts = [line_parts[0]] + [":".join(line_parts[1:])]

rankers commented 9 years ago

Ahh no - I see @nyue has already put a way better fix - its just not released yet. I'll just clone from here rather than pip installing.

Didn't know you could pass a second argument to split to limit the number. Nice.

eriwen commented 9 years ago

I have released @nyue's fix and another one in v1.5 -- pushed to PyPI last night.

Please re-open this issue if anyone's problem's aren't handled.