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

-o option no longer works with relative paths #14

Closed
nedbat opened this issue Jul 27, 2009 · 4 comments
Closed

-o option no longer works with relative paths #14

nedbat opened this issue Jul 27, 2009 · 4 comments
Labels
bug Something isn't working

Comments

@nedbat
Copy link
Owner

nedbat commented Jul 27, 2009

Originally reported by Geoff Bache (Bitbucket: geoffbache, GitHub: Unknown)


In coverage 2.* it always used to work to just write
coverage -o , even though the documentation said "-o" was for absolute path prefixes. I found this ability fairly useful as I have third-party code inside my source tree. Would it be possible to restore this functionality?

(I have a patch for this which I will attach shortly)


@nedbat
Copy link
Owner Author

nedbat commented Jul 27, 2009

Original comment by Geoff Bache (Bitbucket: geoffbache, GitHub: Unknown)


Posted a simple fix (output of "hg bundle", hope this is OK) that essentially removes the code that converts all omit arguments to absolute paths (and adds a unit test for it). After all, source code files are referred by relative path name at this point if possible anyway, so converting to absolute paths only has the affect of making these references not work as far as I can see. If they were absolute to start with it will of course have no effect.

@nedbat
Copy link
Owner Author

nedbat commented Sep 29, 2009

Original comment by rozza (Bitbucket: rozza, GitHub: rozza)


It would be nice if you could override the factory in an easy manner - as I like the regex style omission of files (similar to figleaf) - and in the end I had to overwrote the code_unit_factory:

#!python
    if omit_prefixes:
        exclude_patterns = [re.compile(line.strip()) for line in omit_prefixes if line and not line.startswith('#')]
        filtered = []
        for cu in code_units:
            skip = False
            for pattern in exclude_patterns:
                if pattern.search(cu.filename):
                    skip = True
                    break
                
            if not skip:
                filtered.append(cu)
        code_units = filtered

It would be nice to have some way of hooking or extending this cleanly.

@nedbat
Copy link
Owner Author

nedbat commented Nov 20, 2009

The relative module problem is fixed in <<changeset 24db72e45ad8 (bb)>>.

I moved the regex request to <<issue 36>>.

@nedbat nedbat closed this as completed Nov 20, 2009
@nedbat
Copy link
Owner Author

nedbat commented Feb 25, 2010

Removing version: 3.0.1 (automated comment)

@nedbat nedbat added major bug Something isn't working labels Jun 23, 2018
agronholm added a commit to agronholm/coveragepy that referenced this issue Aug 16, 2020
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