aconrad / pycobertura

A code coverage diff tool for Cobertura reports
MIT License
116 stars 39 forks source link

Bug using ZipFileSystem and DirectoryFileSystem together #107

Closed chezihp closed 1 year ago

chezihp commented 3 years ago

Hey, Thanks for this project. Really helpful! Im using both ZipFileSystem and DirectoryFileSystem together (one for Cobertura1 and the other for Cobertura2). Found out that the line mapping between the two FileSystems is not working properly because ZipFileSystem adds 'b' prefix to each source line (this is expected) while DirectoryFileSystem doesn't. This effects cases for example when the same source line is missed in both coverage.xml files but the line still marked as status=False and reason="line-edit". The workaround Im currently using is to override the ZipFileSystem.open method and wrapping the opened file with TextIOWrapper.

aconrad commented 3 years ago

Thanks for your report @chezihp, and nice find! Do you get a traceback, on just incorrect output from pycobertura?

Is there any chance for you to put a PR together with a test that displays the failure?

chezihp commented 3 years ago

Hey. Just incorrect output. I'll put a PR as soon I'll find the time to do it.

aconrad commented 2 years ago

Can you provide a reproducible test case?

ernestask commented 1 year ago

pycobertura.zip

➜  pycobertura pycobertura diff --source1 src.zip --source2 . cobertura1.xml cobertura2.xml
Filename      Stmts    Miss  Cover     Missing
----------  -------  ------  --------  ---------
TOTAL             0       0  +100.00%
➜  pycobertura echo $?
3

➜  pycobertura pycobertura diff --source1 . --source2 . cobertura1.xml cobertura2.xml
Filename      Stmts    Miss  Cover     Missing
----------  -------  ------  --------  ---------
TOTAL             0       0  +100.00%
➜  pycobertura echo $?
0