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

Error when using --ignore-regex with diff #190

Open
RamonMeffert opened this issue Jul 29, 2024 · 0 comments
Open

Error when using --ignore-regex with diff #190

RamonMeffert opened this issue Jul 29, 2024 · 0 comments

Comments

@RamonMeffert
Copy link

RamonMeffert commented Jul 29, 2024

Hi! Thanks for making this tool, this seems really useful 😄

I've been playing around with the CLI a bit, and I've basically figured out how to use it. However, it seems like there is a difference between the show and diff commands when using the --ignore-regex option. The show command nicely ignores files matching the regex I give it. However, the diff command throws an error for some regexes:

$ pycobertura diff ./coverage-1.xml ./coverage-2.xml --ignore-regex ".*Tests"
Traceback (most recent call last):
  File "/home/ramon/.local/bin/pycobertura", line 8, in <module>
    sys.exit(pycobertura())
  File "/home/ramon/.local/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/ramon/.local/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/ramon/.local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ramon/.local/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ramon/.local/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/ramon/.local/lib/python3.10/site-packages/pycobertura/cli.py", line 326, in diff
    report = reporter.generate()
  File "/home/ramon/.local/lib/python3.10/site-packages/pycobertura/reporters.py", line 362, in generate
    lines = self.get_report_lines()
  File "/home/ramon/.local/lib/python3.10/site-packages/pycobertura/reporters.py", line 242, in get_report_lines
    indexes_of_files_with_changes = [
  File "/home/ramon/.local/lib/python3.10/site-packages/pycobertura/reporters.py", line 247, in <listcomp>
    diff_total_stmts[i],
IndexError: list index out of range

The problem seems to be the .* at the beginning. When I try a different regex (e.g. simply "Tests"), I get no error but nothing is ignored either.

I've tested it on Windows 11 and on Ubuntu 22.04.3 (under WSL), the same error occurs.

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