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

combine aliases does not work on windows base dir paths (ie: "X:\") #577

Closed
nedbat opened this issue May 4, 2017 · 1 comment
Closed
Labels
bug Something isn't working combine fixed windows

Comments

@nedbat
Copy link
Owner

nedbat commented May 4, 2017

Originally reported by vaab (Bitbucket: vaab, GitHub: vaab)


I produced some .coverage file under windows that needs to be combined.

The paths to be aliased is "T:" (context: I'm using a netshare to automate tests in windows VM)

This doesn't get aliased properly when specifying::

[paths]
source = 
    .
    T:\

Why

because in files.py, in PathAliases.add(..)...

Problem 1:

you'll have these 3 lines::

     # The pattern can't end with a wildcard component.
    pattern = pattern.rstrip(r"\/")
    if pattern.endswith("*"):
        raise CoverageException("Pattern must not end with wildcards.")
    pattern_sep = sep(pattern)

Notice that first the pattern given is stripped from it's ending slashes (first instruction), and then (last instruction) the function sep(..) is called to guess what is the pattern separator... which will not be possible since all slashes have been removed.

Moving the last instruction before the .rstrip(..) seems the way to go.

Problem 2

Having removed the last "/" will make this path as a relative one ("T:" is relative, and "T:/" is not)... thus these following lines will mess badly with the pattern::

    # The pattern is meant to match a filepath.  Let's make it absolute
    # unless it already is, or is meant to match any prefix.
    if not pattern.startswith('*') and not isabs_anywhere(pattern):
        pattern = abs_file(pattern)
    pattern += pattern_sep

A suggested workaround would be to add + pattern_sep in the isabs_anywhere(..) call.


@nedbat nedbat added minor bug Something isn't working labels Jun 23, 2018
@nedbat nedbat removed the 4.4 label Aug 17, 2018
@nedbat nedbat added the combine label Nov 16, 2019
@nedbat nedbat added windows and removed minor labels Jan 15, 2020
vaab added a commit to 0k/coveragepy that referenced this issue Dec 14, 2020
vaab added a commit to 0k/coveragepy that referenced this issue Dec 14, 2020
vaab added a commit to 0k/coveragepy that referenced this issue Dec 26, 2020
@nedbat nedbat closed this as completed in dc0e806 Jan 17, 2021
@nedbat nedbat added the fixed label Jan 17, 2021
nedbat added a commit that referenced this issue Jan 17, 2021
@nedbat
Copy link
Owner Author

nedbat commented Jan 26, 2021

This is now released as part of coverage 5.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working combine fixed windows
Projects
None yet
Development

No branches or pull requests

1 participant