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

Problem with include and omit filename patterns that start with asterisk #163

Closed
nedbat opened this issue Dec 5, 2011 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@nedbat
Copy link
Owner

nedbat commented Dec 5, 2011

Originally reported by Mark Doliner (Bitbucket: markdoliner, GitHub: markdoliner)


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 report.py 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?


@nedbat
Copy link
Owner Author

nedbat commented Dec 5, 2011

Original comment by Mark Doliner (Bitbucket: markdoliner, GitHub: markdoliner)


FYI this happens with include and omit patterns listed in a .coveragerc file, too.

@nedbat
Copy link
Owner Author

nedbat commented Dec 21, 2011

Original comment by Дмитрий (Bitbucket: divius, GitHub: Unknown)


Hi guys!

I've found a problem that looks similar.
For me omit="*..." always produce an empty report.
E.g.:

coverage.report(include="*/pycom/*", omit="*banana!",
                ignore_errors=False, show_missing=True)

produces empty report while

coverage.report(include="*/pycom/*",
                ignore_errors=False, show_missing=True)

produces correct one.

Tested on 3.5.1 and 3.4.

@nedbat
Copy link
Owner Author

nedbat commented Oct 29, 2012

Fixed in <<changeset 29662e9378ca (bb)>>.

@nedbat nedbat closed this as completed Oct 29, 2012
@nedbat nedbat added minor bug Something isn't working labels Jun 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant