pytest-dev/pytest-github-actions-annotate-failures

[bug] Windows issue

henryiii opened this issue · 2 comments

On windows, I get the following error:

2020-08-27T13:21:15.2844962Z ============================= test session starts =============================
2020-08-27T13:21:15.2846225Z platform win32 -- Python 3.5.4, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
2020-08-27T13:21:15.2856396Z rootdir: D:\a\pybind11\pybind11\tests\extra_setuptools, inifile: pytest.ini
2020-08-27T13:21:15.2856774Z plugins: github-actions-annotate-failures-0.1.0
2020-08-27T13:21:15.2967645Z collected 1 item
2020-08-27T13:21:15.2973937Z 
2020-08-27T13:21:16.3035940Z tests\extra_setuptools\test_setuphelper.py 
2020-08-27T13:21:16.3036929Z INTERNALERROR> Traceback (most recent call last):
2020-08-27T13:21:16.3037783Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\site-packages\_pytest\main.py", line 191, in wrap_session
2020-08-27T13:21:16.3038780Z INTERNALERROR>     session.exitstatus = doit(config, session) or 0
2020-08-27T13:21:16.3040222Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\site-packages\_pytest\main.py", line 247, in _main
2020-08-27T13:21:16.3041301Z INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
2020-08-27T13:21:16.3042736Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\site-packages\pluggy\hooks.py", line 286, in __call__
2020-08-27T13:21:16.3043669Z INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
2020-08-27T13:21:16.3045008Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
2020-08-27T13:21:16.3045845Z INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
2020-08-27T13:21:16.3047432Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\site-packages\pluggy\manager.py", line 87, in <lambda>
2020-08-27T13:21:16.3048318Z INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
2020-08-27T13:21:16.3049831Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\site-packages\pluggy\callers.py", line 208, in _multicall
2020-08-27T13:21:16.3050828Z INTERNALERROR>     return outcome.get_result()
2020-08-27T13:21:16.3051847Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\site-packages\pluggy\callers.py", line 80, in get_result
2020-08-27T13:21:16.3052612Z INTERNALERROR>     raise ex[1].with_traceback(ex[2])
2020-08-27T13:21:16.3054013Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\site-packages\pluggy\callers.py", line 187, in _multicall
2020-08-27T13:21:16.3054699Z INTERNALERROR>     res = hook_impl.function(*args)
2020-08-27T13:21:16.3056293Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\site-packages\_pytest\main.py", line 272, in pytest_runtestloop
2020-08-27T13:21:16.3058507Z INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
2020-08-27T13:21:16.3059459Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\site-packages\pluggy\hooks.py", line 286, in __call__
2020-08-27T13:21:16.3060077Z INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
2020-08-27T13:21:16.3060826Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
2020-08-27T13:21:16.3061409Z INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
2020-08-27T13:21:16.3062268Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\site-packages\pluggy\manager.py", line 87, in <lambda>
2020-08-27T13:21:16.3064220Z INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
2020-08-27T13:21:16.3064696Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\site-packages\pluggy\callers.py", line 208, in _multicall
2020-08-27T13:21:16.3064923Z INTERNALERROR>     return outcome.get_result()
2020-08-27T13:21:16.3065214Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\site-packages\pluggy\callers.py", line 80, in get_result
2020-08-27T13:21:16.3065431Z INTERNALERROR>     raise ex[1].with_traceback(ex[2])
2020-08-27T13:21:16.3065659Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\site-packages\pluggy\callers.py", line 187, in _multicall
2020-08-27T13:21:16.3065981Z INTERNALERROR>     res = hook_impl.function(*args)
2020-08-27T13:21:16.3066214Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\site-packages\_pytest\runner.py", line 85, in pytest_runtest_protocol
2020-08-27T13:21:16.3066466Z INTERNALERROR>     runtestprotocol(item, nextitem=nextitem)
2020-08-27T13:21:16.3067953Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\site-packages\_pytest\runner.py", line 100, in runtestprotocol
2020-08-27T13:21:16.3068677Z INTERNALERROR>     reports.append(call_and_report(item, "call", log))
2020-08-27T13:21:16.3070427Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\site-packages\_pytest\runner.py", line 188, in call_and_report
2020-08-27T13:21:16.3071479Z INTERNALERROR>     report = hook.pytest_runtest_makereport(item=item, call=call)
2020-08-27T13:21:16.3072890Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\site-packages\pluggy\hooks.py", line 286, in __call__
2020-08-27T13:21:16.3073664Z INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
2020-08-27T13:21:16.3075176Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
2020-08-27T13:21:16.3075983Z INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
2020-08-27T13:21:16.3077543Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\site-packages\pluggy\manager.py", line 87, in <lambda>
2020-08-27T13:21:16.3078823Z INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
2020-08-27T13:21:16.3080086Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\site-packages\pluggy\callers.py", line 203, in _multicall
2020-08-27T13:21:16.3080361Z INTERNALERROR>     gen.send(outcome)
2020-08-27T13:21:16.3081079Z INTERNALERROR>   File "C:\hostedtoolcache\windows\Python\3.5.4\x64\lib\site-packages\pytest_github_actions_annotate_failures\plugin.py", line 33, in pytest_runtest_makereport
2020-08-27T13:21:16.3081455Z INTERNALERROR>     rel_path = os.path.relpath(full_path, workspace)
2020-08-27T13:21:16.3082026Z INTERNALERROR>   File "c:\hostedtoolcache\windows\python\3.5.4\x64\lib\ntpath.py", line 574, in relpath
2020-08-27T13:21:16.3082301Z INTERNALERROR>     path_drive, start_drive))
2020-08-27T13:21:16.3082763Z INTERNALERROR> ValueError: path is on mount 'C:', start on mount 'D:'
2020-08-27T13:21:16.3103555Z 
2020-08-27T13:21:16.3105238Z ============================ no tests ran in 1.03s ============================
2020-08-27T13:21:16.5068822Z ##[error]Process completed with exit code 1.

We need to add protection for the relpath call (try/except ValueError), and there may be an issue with the path reporting. I'm thinking that we now have the path available via "item", which is a little harder for our testing (since it reports the true, GitHub path even when you are trying to fake it), but that's what we actually need in practice. (might fix #19)

Raising ValueError was fixed with #24, but there may be path reporting problem on Windows.

I released v0.1.2 containing #24 which avoids ValueError on Windows.