Skip to content

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

Description

@RamonMeffert

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions