question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Explicit path alias matching order for coverage combine

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nedbatcommented, Dec 1, 2019

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

0reactions
nedbatcommented, Dec 3, 2022

This is now released as part of coverage 7.0.0b1.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Command line usage — Coverage.py 7.0.0 documentation
To combine data for a source file, coverage has to find its data in each of the data files. Different test runs may...
Read more >
Customize pipeline configuration - GitLab Docs
Set up a coverage regular expression for all jobs you want to include in the overall coverage value. Go to your project and...
Read more >
mod_alias - Apache HTTP Server Version 2.4
First, all Redirects are processed before Aliases are processed, and therefore a request that matches a Redirect or RedirectMatch will never have Aliases...
Read more >
Cisco MDS 9000 Family NX-OS Fabric Configuration Guide
If two fabrics are running in different modes and the device alias merge fails between the fabrics, the conflict can be resolved by...
Read more >
Refactor aliased @ imports to relative paths - Stack Overflow
For instance, a project that uses aliases needs to be merged with another project that doesn't use aliases, configuring the latter to use ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found