Xavier de Gaye <xdeg...@gmail.com> added the comment:

To debug and reproduce the problem on Android, one must checkout from the 
bpo-30386 branch 
https://github.com/python/cpython/pull/1629/commits/c0ca089220cd39851d7625b55510be63b340e188.

faulthandler._sigsegv() does crash the crasher in test_crashed, so test_crashed 
must not be disabled.

> How is it possible that the new file that alters the environment be a 
> test_python_* directory (see my initial post) when all the tests are run 
> inside a TEMPDIR/test_python_* directory.

Both test_crashed tests are run in nested tests directories (i.e. in 
$TEMPDIR/test_python_*/test_python_*) on Android. As a consequence the 
test_python_* directory that is not removed by the crasher because it crashed, 
is reported by test_crashed as altering the environment. This also explains the 
other points raised previously.

A remote interactive shell is run by the 'adb shell' command and the TMPDIR 
environment variable is set in that shell. A command may be run remotely with 
the command 'adb shell /path/to/command' and the TMPDIR variable is *not set* 
(but most if not all the other shell environment variables are set) and since 
on Android /tmp does not exist, then tempfile.gettempdir() uses the current 
directory. This explains why the test directories are doubly nested.

On the commit that is the child of commit c0ca089220cd39... which we are using 
here, TMPDIR has been made to be set in the script that runs 
Tools/script/run_tests.py and so it does fix inadvertently the issue for the 
reason explained in the previous paragraph.

This bug can only exist on platforms where tempfile.gettempdir() falls back to 
using the current directory because '/tmp', '/var/tmp' and '/usr/tmp' do not 
exist and where none of the 'TMPDIR', 'TEMP', 'TMP' variables is set. Therefore 
we can either close this issue as not a bug or use the following patch that 
fixes the problem, it is similar to the fix made in issue 15300:

diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
index 8364767b3a..3a213e12c4 100644
--- a/Lib/test/test_regrtest.py
+++ b/Lib/test/test_regrtest.py
@@ -468,10 +468,13 @@ class BaseTestCase(unittest.TestCase):
             input = ''
         if 'stderr' not in kw:
             kw['stderr'] = subprocess.PIPE
+        savedcwd = (support.SAVEDCWD if
+                    any(x.startswith('-j') for x in args) else None)
         proc = subprocess.run(args,
                               universal_newlines=True,
                               input=input,
                               stdout=subprocess.PIPE,
+                              cwd=savedcwd,
                               **kw)
         if proc.returncode != exitcode:
             msg = ("Command %s failed with exit code %s\n"

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32246>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to