Skip to content

Use forward slashes in relative paths on Windows #991

Closed
@inkychris

Description

@inkychris

Current Problem
I'm running coverage for multiple Python versions on both Linux and Windows. They are all run on Gitlab, with the Windows tests using Python install on the host, and with the Linux tests using Docker. The paths of the build directories are not deterministic (may be picked up by multiple runners, existing or yet to exist) so I have relative_files = True .

The Windows paths use \ instead of / which, if the coverage combination and reporting is done on Windows, results in a report with every source file twice, one for each separator, although the end result appears to be correct. If this is done on Linux, it fails entirely when trying to resolve the paths containing backslashes.

Example Report

Name                                           Stmts   Miss Branch BrPart  Cover
 --------------------------------------------------------------------------------
 exmpl\__about__.py                                 6      0      0      0   100%
 exmpl/__about__.py                                 6      0      0      0   100%
 exmpl/__init__.py                                298     11    138      5    95%
 exmpl\__init__.py                                298     11    138      5    95%
 exmpl/_logging.py                                 47      2     16      1    92%
 exmpl\_logging.py                                 47      2     16      1    92%
 exmpl/cli.py                                      55      0     28      0   100%
 exmpl\cli.py                                      55      0     28      0   100%
etc...

Describe the solution you'd like
Source paths on Windows should use forward slashes in relative paths to allow result combination and final reporting to be done on Linux, and to clean up the report output when done on Windows.

Describe alternatives you've considered
Manually modifying the coverage results generated from coverage run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions