coveragepy
coveragepy copied to clipboard
WIN32: data.combine_parallel_data fails in relpath in message
Describe the bug
Whenever on Windows data_paths
are on a disk different from that of the current dir's, there will be a well-known relpath failure.
The actual use of relpath
here is irrelevant and can be replaced with the path itself:
https://github.com/nedbat/coveragepy/blob/b8cb29e53ee6d3a2fda8a342de72e3fefec7d547/coverage/data.py#L135
----------------------------------------------------------------------
Traceback (most recent call last):
File "d:\a\pybuilder\pybuilder\src\integrationtest\python\issue_862_tests.py", line 68, in test
reactor.build("coverage")
File "d:\a\pybuilder\pybuilder\target\dist\pybuilder-0.13.7.dev\pybuilder\reactor.py", line 235, in build
execution_summary = self.build_execution_plan(tasks, execution_plan)
File "d:\a\pybuilder\pybuilder\target\dist\pybuilder-0.13.7.dev\pybuilder\reactor.py", line 272, in build_execution_plan
task_execution_summaries = self.execution_manager.execute_execution_plan(
File "d:\a\pybuilder\pybuilder\target\dist\pybuilder-0.13.7.dev\pybuilder\execution.py", line 393, in execute_execution_plan
summaries.append(self.execute_task(task, **kwargs))
File "d:\a\pybuilder\pybuilder\target\dist\pybuilder-0.13.7.dev\pybuilder\execution.py", line 340, in execute_task
task.execute(self.logger, kwargs, _executable=_executable)
File "d:\a\pybuilder\pybuilder\target\dist\pybuilder-0.13.7.dev\pybuilder\execution.py", line 179, in execute
executable.execute(argument_dict)
File "d:\a\pybuilder\pybuilder\target\dist\pybuilder-0.13.7.dev\pybuilder\execution.py", line 95, in execute
self.callable(*arguments)
File "d:\a\pybuilder\pybuilder\target\dist\pybuilder-0.13.7.dev\pybuilder\plugins\python\coverage_plugin.py", line 142, in coverage
task_cov = run_coverage(project, logger, reactor,
File "d:\a\pybuilder\pybuilder\target\dist\pybuilder-0.13.7.dev\pybuilder\plugins\python\coverage_plugin.py", line 225, in run_coverage
cov.combine()
File "c:\users\runner~1\appdata\local\temp\integrationtestsupporta9jsd0xue052d3a457cd4b2b90193755deba81b1\.pybuilder\plugins\cpython-3.10.5.final.0\lib\site-packages\coverage\control.py", line 748, in combine
combine_parallel_data(
File "c:\users\runner~1\appdata\local\temp\integrationtestsupporta9jsd0xue052d3a457cd4b2b90193755deba81b1\.pybuilder\plugins\cpython-3.10.5.final.0\lib\site-packages\coverage\data.py", line 135, in combine_parallel_data
message(f"Combined data file {os.path.relpath(f)}")
File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\ntpath.py", line 718, in relpath
raise ValueError("path is on mount %r, start on mount %r" % (
ValueError: path is on mount 'c:', start on mount 'D:'
This appears on all Python versions (3.7 - 3.11) on GitHub Action Windows with and without virtualenv.
This reared its head as part of pybuilder/pybuilder#862: https://github.com/pybuilder/pybuilder/runs/7585801888?check_suite_focus=true
This is very similar to #895.
There's also another call to os.path.relpath
that can potentially fail on win32
:
https://github.com/nedbat/coveragepy/blob/30a249aac87be4701bfafae2ed3c5a6e964aa3fc/coverage/xmlreport.py#L173
I will try to propose a pull request along the lines of #896, catching the ValueError
on both of these occurrences.
Nevermind, xmlreport.py
is fine as it is now: rel_name
and dirname
should always be on the same volume.
@nedbat could you please take a look?
@nedbat could I ask for a revision release to incorporate this fix, please?
This is now released as part of coverage 6.4.3.