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

Handle Windows/Unix path separator differences in combine #903

Closed
lazka opened this issue Dec 20, 2019 · 5 comments
Closed

Handle Windows/Unix path separator differences in combine #903

lazka opened this issue Dec 20, 2019 · 5 comments
Labels
enhancement New feature or request question Further information is requested windows

Comments

@lazka
Copy link

lazka commented Dec 20, 2019

Is your feature request related to a problem? Please describe.

I'm generating coverage data on Windows and Linux machines and want to combine them to a final html report. To get the different base paths sorted I use the new relative_path option which works nicely (except for #899), thanks for that!

The problem now is that the combine command doesn't merge "foo/bar/quux.py" with "foo\bar\quux.py" and as a result they get treated as separate files.

When I then try to generate a html report it complains that "foo\bar\quux.py" doesn't exist.

Describe the solution you'd like

I'd like that combine normalizes the path separators to "/" (which is valid on Windows as well) before trying to combine two reports or that the paths get normalized to "/" before being written to the sqlite DB.

Example Data

Here are two .coverage files for the same test run on Windows an Linux as an example:
coverage-example.zip

@lazka lazka added the enhancement New feature or request label Dec 20, 2019
@nedbat nedbat added the windows label Dec 21, 2019
gnomesysadmins pushed a commit to GNOME/pygobject that referenced this issue Dec 27, 2019
It has changed its internal format to sqlite and still doesn't
provide a way to merge runs from different OSes, see
nedbat/coveragepy#903
gnomesysadmins pushed a commit to GNOME/pygobject that referenced this issue Dec 30, 2019
It has changed its internal format to sqlite and still doesn't
provide a way to merge runs from different OSes, see
nedbat/coveragepy#903
@lazka
Copy link
Author

lazka commented Jan 4, 2020

In case anyone is facing the same problem, here is a script to fix the files before combining:

import sys
import sqlite3

def main(argv):
    paths = argv[1:]

    for path in paths:
        # https://github.com/nedbat/coveragepy/issues/903
        conn = sqlite3.connect(path)
        conn.execute("UPDATE file set path = REPLACE(path, '\\', '/')")
        conn.commit()
        conn.close()

if __name__ == "__main__":
    sys.exit(main(sys.argv))

@greg-hellings
Copy link

Just ran into this problem myself. The script from @lazka worked flawlessly. Thanks!

@nedbat
Copy link
Owner

nedbat commented Nov 6, 2021

(Sorry this has gotten so stale...) Do you have a way to demonstrate the problem? When you use the [paths] setting, the path separators should be mapped together as you want.

@nedbat nedbat added the question Further information is requested label Nov 6, 2021
@nedbat nedbat added this to the Next milestone Nov 6, 2021
@nedbat nedbat added the next label Nov 13, 2021
@nedbat nedbat removed this from the Next milestone Nov 13, 2021
@nedbat
Copy link
Owner

nedbat commented Feb 3, 2022

Feel free to re-open this if you can provide more information.

@nedbat nedbat closed this as completed Feb 3, 2022
@nedbat nedbat removed the next label Feb 3, 2022
@lazka
Copy link
Author

lazka commented Mar 27, 2022

As they don't share a common prefix I don't know how I would use "[paths]". I tried some things (creating a dummy paths entry) but there was no change.

  • Use coverage.zip
  • Run coverage combine --keep
  • Run sqlite3 .coverage "select * from file"
  • See that the resulting coverage file contains duplicate entries for everything

@nedbat I don't have rights to re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested windows
Projects
None yet
Development

No branches or pull requests

3 participants