MagicStack / MagicStack/uvloop

test_process_env_2 not portable to non-FHS systems

Open
#647 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Cython
Stars
11.9k
Forks
616
PR merge metrics
No merged PRs in 30d

Description

  • uvloop version: 0.21.0
  • Python version: 3.10
  • Platform: GNU Guix

This test code:

    def test_process_env_2(self):
        async def test():
            cmd = 'env'
            env = {}  # empty environment
            proc = await asyncio.create_subprocess_exec(
                cmd,
                env=env,
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE)

            out, _ = await proc.communicate()
            self.assertEqual(out, b'')
            self.assertEqual(proc.returncode, 0)

        self.loop.run_until_complete(test())

fails like:

=================================== FAILURES ===================================
______________________ Test_UV_Process.test_process_env_2 ______________________
Traceback (most recent call last):
  File "/gnu/store/jjcka1g6sk2cvwx8nm4fdwpdq3vll0v0-python-3.10.7/lib/python3.10/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/gnu/store/jjcka1g6sk2cvwx8nm4fdwpdq3vll0v0-python-3.10.7/lib/python3.10/unittest/case.py", line 591, in run
    self._callTestMethod(testMethod)
  File "/gnu/store/jjcka1g6sk2cvwx8nm4fdwpdq3vll0v0-python-3.10.7/lib/python3.10/unittest/case.py", line 549, in _callTestMethod
    method()
  File "/tmp/guix-build-python-uvloop-0.21.0.drv-0/uvloop-0.21.0/tests/test_process.py", line 67, in test_process_env_2
    self.loop.run_until_complete(test())
  File "uvloop/loop.pyx", line 1518, in uvloop.loop.Loop.run_until_complete
  File "/tmp/guix-build-python-uvloop-0.21.0.drv-0/uvloop-0.21.0/tests/test_process.py", line 57, in test
    proc = await asyncio.create_subprocess_exec(
  File "/gnu/store/jjcka1g6sk2cvwx8nm4fdwpdq3vll0v0-python-3.10.7/lib/python3.10/asyncio/subprocess.py", line 218, in create_subprocess_exec
    transport, protocol = await loop.subprocess_exec(
  File "uvloop/loop.pyx", line 2841, in subprocess_exec
  File "uvloop/loop.pyx", line 2799, in __subprocess_run
  File "uvloop/handles/process.pyx", line 611, in uvloop.loop.UVProcessTransport.new
  File "uvloop/dns.pyx", line 112, in uvloop.loop.__convert_pyaddr_to_sockaddr
FileNotFoundError: [Errno 2] No such file or directory
_____________________ Test_AIO_Process.test_process_env_2 ______________________
Traceback (most recent call last):
  File "/gnu/store/jjcka1g6sk2cvwx8nm4fdwpdq3vll0v0-python-3.10.7/lib/python3.10/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/gnu/store/jjcka1g6sk2cvwx8nm4fdwpdq3vll0v0-python-3.10.7/lib/python3.10/unittest/case.py", line 591, in run
    self._callTestMethod(testMethod)
  File "/gnu/store/jjcka1g6sk2cvwx8nm4fdwpdq3vll0v0-python-3.10.7/lib/python3.10/unittest/case.py", line 549, in _callTestMethod
    method()
  File "/tmp/guix-build-python-uvloop-0.21.0.drv-0/uvloop-0.21.0/tests/test_process.py", line 67, in test_process_env_2
    self.loop.run_until_complete(test())
  File "/gnu/store/jjcka1g6sk2cvwx8nm4fdwpdq3vll0v0-python-3.10.7/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/tmp/guix-build-python-uvloop-0.21.0.drv-0/uvloop-0.21.0/tests/test_process.py", line 57, in test
    proc = await asyncio.create_subprocess_exec(
  File "/gnu/store/jjcka1g6sk2cvwx8nm4fdwpdq3vll0v0-python-3.10.7/lib/python3.10/asyncio/subprocess.py", line 218, in create_subprocess_exec
    transport, protocol = await loop.subprocess_exec(
  File "/gnu/store/jjcka1g6sk2cvwx8nm4fdwpdq3vll0v0-python-3.10.7/lib/python3.10/asyncio/base_events.py", line 1667, in subprocess_exec
    transport = await self._make_subprocess_transport(
  File "/gnu/store/jjcka1g6sk2cvwx8nm4fdwpdq3vll0v0-python-3.10.7/lib/python3.10/asyncio/unix_events.py", line 207, in _make_subprocess_transport
    transp = _UnixSubprocessTransport(self, protocol, args, shell,
  File "/gnu/store/jjcka1g6sk2cvwx8nm4fdwpdq3vll0v0-python-3.10.7/lib/python3.10/asyncio/base_subprocess.py", line 36, in __init__
    self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
  File "/gnu/store/jjcka1g6sk2cvwx8nm4fdwpdq3vll0v0-python-3.10.7/lib/python3.10/asyncio/unix_events.py", line 799, in _start
    self._proc = subprocess.Popen(
  File "/gnu/store/jjcka1g6sk2cvwx8nm4fdwpdq3vll0v0-python-3.10.7/lib/python3.10/subprocess.py", line 969, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/gnu/store/jjcka1g6sk2cvwx8nm4fdwpdq3vll0v0-python-3.10.7/lib/python3.10/subprocess.py", line 1845, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'env'

This is because on non-file-hierarchy-standard systems like GNU Guix and Nix, env is not found at some fixed location burnt on the implicit PATH value; instead it must be looked from PATH, but the tests clears it.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tests/test_process.py and the test_process_env_2 cases shown in the report, comparing the uvloop and asyncio failures on GNU Guix. Make the test locate the env executable without relying on a fixed implicit PATH, then verify both implementations complete successfully with empty output and return code 0 on non-FHS systems.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
operating-systems, testing-qa
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.