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

Explicit path alias matching order for coverage combine #649

Closed
nedbat opened this issue Mar 14, 2018 · 3 comments
Closed

Explicit path alias matching order for coverage combine #649

nedbat opened this issue Mar 14, 2018 · 3 comments
Labels

Comments

@nedbat
Copy link
Owner

@nedbat nedbat commented Mar 14, 2018

Originally reported by Jonathan Beezley (Bitbucket: jbeezley, GitHub: jbeezley)


Over in https://github.com/girder/girder, we have a fairly convoluted use case where we need to use path aliases for our coverage combine step, but we also need ensure that the matching occurs in the correct order. To gloss over some of the messy details, the issue is that in a development install we have the following directory structure:

root/ ->
    girder/
        __init__.py
        ...
    plugins/
        __init__.py
        ...

But when installed, the package looks like this:

root/ ->
    girder/
        __init__.py
        ...
        plugins/
            __init__.py
            ...

We need to be able to combine coverage files executed from both of these environments,so we use a path alias that looks like this:

[coverage:paths]
plugins =
    plugins/
    build/test/tox/*/lib/*/site-packages/girder/plugins/
girder = 
    girder/
    build/test/tox/*/lib/*/site-packages/girder/

The issue here is that it matches the girder section first and aliases the plugin modules to $PWD/girder/plugins rather than $PWD/plugins.

Globbing patterns don't allow us to exclude only certain subdirectories from the second group, so we need to have some way to ensure that the it is matched after the first.

I would be willing to implement one of the following solutions. I would appreciate any guidance as to which approach (if any) would be preferred by the maintainers.

  1. Somehow allow explicit regex's in the path matching. I'm not sure how the syntax of this would work.
  2. Use an OrderedDict on this line so that the original order in the config file is preserved. This would be ideal, but it would require a backport of OrderedDict for python 2.6 support.
  3. Iterate through the keys in sorted order on this line. Users could then choose to name the alias targets so they apply in the required order. This is the simplest solution that I can think of, but it smells a little hacky to me.

@nedbat nedbat removed the 4.5 label Aug 17, 2018
@nedbat

This comment has been minimized.

Copy link
Owner Author

@nedbat nedbat commented Sep 6, 2018

@jbeezley An OrderedDict sounds like a good approach. I've dropped Python 2.6 support since you wrote this up.

nedbat added a commit that referenced this issue Dec 1, 2019
@nedbat

This comment has been minimized.

Copy link
Owner Author

@nedbat nedbat commented Dec 1, 2019

I've fixed this in 65b9007. Thanks for the detailed example. It's now enshrined in my test suite!

@nedbat nedbat closed this Dec 1, 2019
nedbat added a commit that referenced this issue Dec 1, 2019
@nedbat

This comment has been minimized.

Copy link
Owner Author

@nedbat nedbat commented Dec 8, 2019

This was released as part of 5.0b2 today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.