Problem with include and omit filename patterns that start with asterisk

Issue #163 resolved
Mark Doliner created an issue

Using the coverage api, say I pass in include or omit parameters that look like this: {{{ cov.html_report( directory='/home/mark/someproject', include=['.py'] ) }}} or {{{ cov.html_report( directory='/home/mark/someproject', omit=['.js'] ) }}}

When this runs, the include and omit patterns get munged into an absolute path which is relative to the current working directory. This happens because the find_code_units() function in calls file_locator.abs_file() for each pattern.

This is fine if the current working directory is /home/mark/someproject/. But it causes problems if the current working directory is /home/mark/someproject/tests/. In this case the pattern is munged to '/home/mark/someproject/tests/*.py', which won't match the source code for my project.

I can work around this by simply adding a slash to the beginning of my patterns. This changes the pattern to an absolute path and file_locator.abs_file() will not alter it.

I don't think I understand the reason for calling file_locator.abs_file() on the patterns in this case... maybe we could just remove that?

Comments (3)

  1. Дмитрий

    Hi guys!

    I've found a problem that looks similar. For me omit="*..." always produce an empty report. E.g.:"*/pycom/*", omit="*banana!",
                    ignore_errors=False, show_missing=True)

    produces empty report while"*/pycom/*",
                    ignore_errors=False, show_missing=True)

    produces correct one.

    Tested on 3.5.1 and 3.4.

  2. Log in to comment