Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duplicate matches in --excludes will lead to errors #53

Open
dothebart opened this issue Feb 20, 2024 · 0 comments
Open

duplicate matches in --excludes will lead to errors #53

dothebart opened this issue Feb 20, 2024 · 0 comments

Comments

@dothebart
Copy link

It seems if more that one --excludes wants to match on a single item one gets uncaught exceptions.
Changing it to an error message instead:

diff --git a/lcov_cobertura/lcov_cobertura.py b/lcov_cobertura/lcov_cobertura.py
index 379e405..3faf7a9 100755
--- a/lcov_cobertura/lcov_cobertura.py
+++ b/lcov_cobertura/lcov_cobertura.py
@@ -217,7 +217,10 @@ class LcovCobertura():
         excluded = [x for x in coverage_data['packages'] for e in self.excludes
                     if re.match(e, x)]
         for package in excluded:
-            del coverage_data['packages'][package]
+            try:
+                del coverage_data['packages'][package]
+            except KeyError as ex:
+                print(f"skipping filter for {package} - not found; duplicate exclude pattern match?")
 
         # Compute line coverage rates
         for package_data in list(coverage_data['packages'].values()):
@@ -425,8 +428,8 @@ def main(argv=None):
             cobertura_xml = lcov_cobertura.convert()
         with open(options.output, mode='wt') as output_file:
             output_file.write(cobertura_xml)
-    except IOError:
-        sys.stderr.write("Unable to convert %s to Cobertura XML" % args[1])
+    except IOError as ex:
+        sys.stderr.write("Unable to convert %s to Cobertura XML %s" % (args[1], ex))
 
 
 if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant