Azure / pytest-azurepipelines

Plugin for pytest that makes it simple to work with Azure Pipelines
MIT License
112 stars 35 forks source link

´ERROR: file or directory not found: for´ - Exit Code 4 - Windows #64

Closed florianfischer91 closed 2 years ago

florianfischer91 commented 2 years ago

I'm running pytest with pytest-azurepipelines in a CI-Pipeline on Azure. For Linux everything works fine but for Windows i get an error when calling

python -m pytest -vvv --debug --test-run-title='Test for OS $(imageName) with Python $(python.version)'

Here is the output of the pipeline

============================= test session starts =============================
platform win32 -- Python 3.9.10, pytest-7.1.1, pluggy-1.0.0 -- C:\hostedtoolcache\windows\Python\3.9.10\x64\python.exe
using: pytest-7.1.1
setuptools registered plugins:
  anyio-3.5.0 at C:\hostedtoolcache\windows\Python\3.9.10\x64\lib\site-packages\anyio\pytest_plugin.py
  pytest-azurepipelines-1.0.3 at C:\hostedtoolcache\windows\Python\3.9.10\x64\lib\site-packages\pytest_azurepipelines.py
  pytest-nunit-1.0.0 at C:\hostedtoolcache\windows\Python\3.9.10\x64\lib\site-packages\pytest_nunit\plugin.py
cachedir: .pytest_cache
rootdir: D:\a\1\s
plugins: anyio-3.5.0, azurepipelines-1.0.3, nunit-1.0.0
wrote pytest debug information to pytestdebug.log
ERROR: file or directory not found: for

collecting ... collected 0 items
Result Attachments will be stored in LogStore
Run Attachments will be stored in LogStore
No Result Found to Publish 'D:\a\1\s\test-output.xml'.
Skipping uploading of coverage data.

------------- generated Nunit xml file: D:\a\1\s\test-output.xml --------------
============================ no tests ran in 0.01s ============================
##[error]Cmd.exe exited with code '4'.
Async Command Start: Publish test results
Async Command End: Publish test results
Finishing: Run tests

And the end of the pytestdebug.log

    perform_collect <Session s exitstatus=<ExitCode.OK: 0> testsfailed=0 testscollected=0> ['for', 'OS', 'windows-latest', 'with', 'Python', "3.9'"] [collection]
        pytest_collection_finish [hook]
            session: <Session s exitstatus=<ExitCode.OK: 0> testsfailed=0 testscollected=0>
          pytest_report_collectionfinish [hook]
              config: <_pytest.config.Config object at 0x000002946928B7C0>
              items: []
              start_path: D:\a\1\s
              startdir: D:\a\1\s
          finish pytest_report_collectionfinish --> [] [hook]
        finish pytest_collection_finish --> [] [hook]
      pytest_sessionfinish [hook]
          session: <Session s exitstatus=<ExitCode.USAGE_ERROR: 4> testsfailed=0 testscollected=0>
          exitstatus: 4
        pytest_terminal_summary [hook]
            terminalreporter: <_pytest.terminal.TerminalReporter object at 0x000002946A2A2580>
            exitstatus: 4
            config: <_pytest.config.Config object at 0x000002946928B7C0>
        finish pytest_terminal_summary --> [] [hook]
      finish pytest_sessionfinish --> [] [hook]
      pytest_unconfigure [hook]
          config: <_pytest.config.Config object at 0x000002946928B7C0>
      finish pytest_unconfigure --> [] [hook]

I have the same setup (of course with different tests) in a different Pipeline where i use pytest 6.2.4. There everything works as expected (for Linux and Windows)

Does anybody has an idea what the problem could be?

florianfischer91 commented 2 years ago

Solved by using bash instead of script for the task definition in my pipeline file. I guess the problem is related to pytest-dev/pytest#9431