changeset 46326:3e23794b9e1c

run-tests: work around the Windows firewall popup for server processes Windows doesn't have a `python3` executable, so cc0b332ab9fc attempted to work around the issue by copying the current python to `python3.exe`. That put it in `_tmpbindir` because of failures in `test-run-tests.t` when using `_bindir`, which looked like a process was trying to open it to write out a copy while it was in use. (Interestingly, I couldn't reproduce this running the test by itself in a loop for a couple of hours, but it happens constantly when running all tests.) The problem with using `_tmpbindir` is that it is the randomly generated path for the test run, and instead of Windows Firewall remembering the executable signature or image hash when allowing the process to open a server port, it apparently remembers the image path. That means every run will trigger a popup to allow it, which is bad for firing off a test run and walking away. I tried to symlink to the python executable, but that currently requires admin priviledges[1]. This will prompt the first time if the underlying python binary has never opened a server port, but appears to avoid it on subsequent runs. [1] https://bugs.python.org/issue40687 Differential Revision: https://phab.mercurial-scm.org/D9815
author Matt Harbison <matt_harbison@yahoo.com>
date Mon, 18 Jan 2021 00:50:01 -0500
parents e5e6282fa66a
children 85c0c7145f8e
files .hgignore tests/run-tests.py
diffstat 2 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Sun Jan 17 22:25:15 2021 -0500
+++ b/.hgignore	Mon Jan 18 00:50:01 2021 -0500
@@ -26,6 +26,7 @@
 tests/hypothesis-generated
 tests/annotated
 tests/exceptions
+tests/python3
 tests/*.err
 tests/htmlcov
 build
--- a/tests/run-tests.py	Sun Jan 17 22:25:15 2021 -0500
+++ b/tests/run-tests.py	Mon Jan 18 00:50:01 2021 -0500
@@ -3470,14 +3470,13 @@
                         raise
         else:
             # Windows doesn't have `python3.exe`, and MSYS cannot understand the
-            # reparse point with that name provided by Microsoft.  Copy the
-            # current interpreter to PATH with that name so the shebang lines
-            # work.
+            # reparse point with that name provided by Microsoft.  Create a
+            # simple script on PATH with that name that delegates to the py3
+            # launcher so the shebang lines work.
             if os.getenv('MSYSTEM'):
-                shutil.copy(
-                    sys.executable,
-                    _bytes2sys(self._tmpbindir + b'/python3.exe'),
-                )
+                with open(osenvironb[b'RUNTESTDIR'] + b'/python3', 'wb') as f:
+                    f.write(b'#!/bin/sh\n')
+                    f.write(b'py -3 "$@"\n')
 
             exedir, exename = os.path.split(sysexecutable)
             vlog(