2

I am using python script to convert lcov file to cobertura format so that I can use Jenkins plugin to show the report in the job. I need to exclude few packages and some files, the python script only provides option to exclude packages. Any other workaround?

https://github.com/eriwen/lcov-to-cobertura-xml

Excludes the entire package, python lcov_cobertura.py lcov.info --excludes sources.modules.web.services.transport -o coverage1.xml

I want to exclude on the "BundleService.js" under transport package, (This doesn't work) python lcov_cobertura.py lcov.info --excludes sources.modules.web.services.transport.BundleService -o coverage2.xml

Tried multiple regex, still no luck.

QE Expert
  • 71
  • 1
  • 2

1 Answers1

0

Solution 1

They use re.match in lcov_cobertura.py to apply excludes.

In python documentation for re.match it is written:

re.match(pattern, string, flags=0)

If zero or more characters at the beginning of string match the regular expression pattern, return a corresponding MatchObject instance. Return None if the string does not match the pattern; note that this is different from a zero-length match.

It means that it searchs from the beggining of package name. And you should specify argument like the following to avoid any starting symbols:

-e ".*sources.modules.web.services.transport"

The quotes are needed to avoid shell expansion for * (important for Linux shells like bash).
The complete command looks like:

python lcov_cobertura.py lcov.info --excludes ".*sources.modules.web.services.transport" -o coverage1.xml

Solution 2

Maybe removing data about specific package in lcov is better idea:

lcov --capture --directory $BINDIR --output-file lcov.info
lcov --remove lcov.info "*sources.modules.web.services.transport" --output-file lcov.info

As mentioned in man lcov:

Use this switch if you want to remove coverage data for a particular set of files from a tracefile. Additional command line parameters will be interpreted as shell wildcard patterns ...

The result of the remove operation will be written to stdout or the tracefile specified with -o.

Community
  • 1
  • 1
Maxim Suslov
  • 4,335
  • 1
  • 35
  • 29