◐ Shell
clean mode source ↗

[WIP] bpo-37421: regrtest detects if a test leaks temporary files by vstinner · Pull Request #14415 · python/cpython

@vstinner

@vstinner

test_concurrent_futures, test_multiprocessing_fork and test_multiprocessing_spawn failed on the Linux job of Travis CI, with errors like:

ERROR: test_socket_fileno (test.test_socket.GeneralModuleTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/python/cpython/Lib/test/test_socket.py", line 1834, in test_socket_fileno
    s.bind(os.path.join(tmpdir, 'socket'))
OSError: AF_UNIX path too long

test_concurrent_futures failed with "1 test altered the execution environment" on the Ubuntu job of Azure Pipelines:

Warning -- tmpdir was modified by test_concurrent_futures
  Before: []
  After:  ['pymp-f8efn6z8'] 
Traceback (most recent call last):
  File "/home/vsts/work/1/s/Lib/multiprocessing/util.py", line 265, in _run_finalizers
    finalizer()
  File "/home/vsts/work/1/s/Lib/multiprocessing/util.py", line 189, in __call__
    res = self._callback(*self._args, **self._kwargs)
  File "/home/vsts/work/1/s/Lib/shutil.py", line 660, in rmtree
    onerror(os.lstat, path, sys.exc_info())
  File "/home/vsts/work/1/s/Lib/shutil.py", line 658, in rmtree
    orig_st = os.lstat(path)
FileNotFoundError: [Errno 2] No such file or directory: '/home/vsts/work/1/s/build/test_python_27082/test_python_worker_29853/tmpdir/pymp-f8efn6z8'

@vstinner

win64 job of Azure Pipelines failed with:

1 test failed:
    test_os

2 tests altered the execution environment:
    test_distutils test_winconsoleio

Warning -- tmpdir was modified by test_winconsoleio
  Before: []
  After:  ['tmp2wme2jy5']

Warning -- tmpdir was modified by test_distutils
  Before: []
  After:  ['tmpu_zkofwq']

======================================================================
ERROR: test_bytes (test.test_os.ReadlinkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\a\1\s\lib\test\support\__init__.py", line 438, in unlink
    _unlink(filename)
  File "D:\a\1\s\lib\test\support\__init__.py", line 371, in _unlink
    _waitfor(os.unlink, filename)
  File "D:\a\1\s\lib\test\support\__init__.py", line 362, in _waitfor
    if not (L if waitall else name in L):
BytesWarning: Comparison between bytes and string

======================================================================
ERROR: test_pathlike_bytes (test.test_os.ReadlinkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\a\1\s\lib\test\support\__init__.py", line 438, in unlink
    _unlink(filename)
  File "D:\a\1\s\lib\test\support\__init__.py", line 371, in _unlink
    _waitfor(os.unlink, filename)
  File "D:\a\1\s\lib\test\support\__init__.py", line 362, in _waitfor
    if not (L if waitall else name in L):
BytesWarning: Comparison between bytes and string

@vstinner

I rebased again this PR to get the 3 other fixes. Remaining issue on Windows:

linkTests) ... test test_os failed
skipped 'currently fails; consider for improvement'
======================================================================
ERROR: test_bytes (test.test_os.ReadlinkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\projects\cpython\lib\test\support\__init__.py", line 438, in unlink
    _unlink(filename)
  File "C:\projects\cpython\lib\test\support\__init__.py", line 371, in _unlink
    _waitfor(os.unlink, filename)
  File "C:\projects\cpython\lib\test\support\__init__.py", line 362, in _waitfor
    if not (L if waitall else name in L):
BytesWarning: Comparison between bytes and string
======================================================================
ERROR: test_pathlike_bytes (test.test_os.ReadlinkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\projects\cpython\lib\test\support\__init__.py", line 438, in unlink
    _unlink(filename)
  File "C:\projects\cpython\lib\test\support\__init__.py", line 371, in _unlink
    _waitfor(os.unlink, filename)
  File "C:\projects\cpython\lib\test\support\__init__.py", line 362, in _waitfor
    if not (L if waitall else name in L):
BytesWarning: Comparison between bytes and string
----------------------------------------------------------------------

Again, the Linux job of Travis CI failed with errors like:

======================================================================
ERROR: test_socket_fileno (test.test_socket.GeneralModuleTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/python/cpython/Lib/test/test_socket.py", line 1834, in test_socket_fileno
    s.bind(os.path.join(tmpdir, 'socket'))
OSError: AF_UNIX path too long

@vstinner

This change causes issues. I'm not sure it's worth it to automate checking for temporary files. I close this PR.