-o option no longer works with relative paths

Issue #14 resolved
Geoff Bache created an issue

In coverage 2.* it always used to work to just write coverage -o <module>, 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)

Comments (4)

  1. Geoff Bache reporter

    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.

  2. Ross Lawley

    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:

        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
                if not skip:
            code_units = filtered

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

  3. Log in to comment