marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Having `python3` actually pointing to `python2` is bad. So we stop doing so.
  
  In addition we need to re-introduce a `python` executable since some of the
  script really need to be able to say "current python" in their shbang. For
  example, `hghave` is one of such script.
  
  The faulty changes where introduced by c102b704edb5 
<https://phab.mercurial-scm.org/rHGc102b704edb5191ed15ed4b02b625a888b8be816>.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10943

AFFECTED FILES
  tests/dumbhttp.py
  tests/dummysmtpd.py
  tests/get-with-headers.py
  tests/hghave
  tests/run-tests.py
  tests/test-filelog.py
  tests/test-remotefilelog-datapack.py
  tests/test-remotefilelog-histpack.py
  tests/test-status-inprocess.py
  tests/test-stdio.py
  tests/tinyproxy.py

CHANGE DETAILS

diff --git a/tests/tinyproxy.py b/tests/tinyproxy.py
--- a/tests/tinyproxy.py
+++ b/tests/tinyproxy.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env python
 
 from __future__ import absolute_import, print_function
 
diff --git a/tests/test-stdio.py b/tests/test-stdio.py
--- a/tests/test-stdio.py
+++ b/tests/test-stdio.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env python
 """
 Tests the buffering behavior of stdio streams in `mercurial.utils.procutil`.
 """
diff --git a/tests/test-status-inprocess.py b/tests/test-status-inprocess.py
--- a/tests/test-status-inprocess.py
+++ b/tests/test-status-inprocess.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env python
 from __future__ import absolute_import, print_function
 
 import sys
diff --git a/tests/test-remotefilelog-histpack.py 
b/tests/test-remotefilelog-histpack.py
--- a/tests/test-remotefilelog-histpack.py
+++ b/tests/test-remotefilelog-histpack.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env python
 from __future__ import absolute_import
 
 import hashlib
diff --git a/tests/test-remotefilelog-datapack.py 
b/tests/test-remotefilelog-datapack.py
--- a/tests/test-remotefilelog-datapack.py
+++ b/tests/test-remotefilelog-datapack.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env python
 from __future__ import absolute_import, print_function
 
 import hashlib
diff --git a/tests/test-filelog.py b/tests/test-filelog.py
--- a/tests/test-filelog.py
+++ b/tests/test-filelog.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env python
 """
 Tests the behavior of filelog w.r.t. data starting with '\1\n'
 """
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -3530,9 +3530,11 @@
         """Configure the environment to use the appropriate Python in tests."""
         # Tests must use the same interpreter as us or bad things will happen.
         if sys.platform == 'win32':
-            pyexename = b'python.exe'
+            pyexe_names = [b'python', b'python.exe']
+        elif sys.version_info[0] < 3:
+            pyexe_names = [b'python', b'python2']
         else:
-            pyexename = b'python3'  # XXX this is wrong with python2...
+            pyexe_names = [b'python', b'python3']
 
         # os.symlink() is a thing with py3 on Windows, but it requires
         # Administrator rights.
@@ -3540,7 +3542,7 @@
             msg = "# Making python executable in test path a symlink to '%s'"
             msg %= sysexecutable
             vlog(msg)
-            for pyexename in [pyexename]:
+            for pyexename in pyexe_names:
                 mypython = os.path.join(self._tmpbindir, pyexename)
                 try:
                     if os.readlink(mypython) == sysexecutable:
@@ -3566,11 +3568,16 @@
                 with open(osenvironb[b'RUNTESTDIR'] + b'/python3', 'wb') as f:
                     f.write(b'#!/bin/sh\n')
                     f.write(b'py -3.%d "$@"\n' % sys.version_info[1])
+            if os.getenv('MSYSTEM'):
+                with open(osenvironb[b'RUNTESTDIR'] + b'/python2', 'wb') as f:
+                    f.write(b'#!/bin/sh\n')
+                    f.write(b'py -2.%d "$@"\n' % sys.version_info[1])
 
             exedir, exename = os.path.split(sysexecutable)
-            msg = "# Modifying search path to find %s as %s in '%s'"
-            msg %= (exename, pyexename, exedir)
-            vlog(msg)
+            for pyexename in pyexe_names:
+                msg = "# Modifying search path to find %s as %s in '%s'"
+                msg %= (exename, pyexename, exedir)
+                vlog(msg)
             path = os.environ['PATH'].split(os.pathsep)
             while exedir in path:
                 path.remove(exedir)
@@ -3598,8 +3605,9 @@
                 extra_paths.append(scripts_dir)
 
             os.environ['PATH'] = os.pathsep.join(extra_paths + path)
-            if not self._findprogram(pyexename):
-                print("WARNING: Cannot find %s in search path" % pyexename)
+            for pyexename in pyexe_names:
+                if not self._findprogram(pyexename):
+                    print("WARNING: Cannot find %s in search path" % pyexename)
 
     def _installhg(self):
         """Install hg into the test environment.
diff --git a/tests/hghave b/tests/hghave
--- a/tests/hghave
+++ b/tests/hghave
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env python
 """Test the running system for features availability. Exit with zero
 if all features are there, non-zero otherwise. If a feature name is
 prefixed with "no-", the absence of feature is tested.
diff --git a/tests/get-with-headers.py b/tests/get-with-headers.py
--- a/tests/get-with-headers.py
+++ b/tests/get-with-headers.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env python
 
 """This does HTTP GET requests given a host:port and path and returns
 a subset of the headers plus the body of the result."""
diff --git a/tests/dummysmtpd.py b/tests/dummysmtpd.py
--- a/tests/dummysmtpd.py
+++ b/tests/dummysmtpd.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env python
 
 """dummy SMTP server for use in tests"""
 
diff --git a/tests/dumbhttp.py b/tests/dumbhttp.py
--- a/tests/dumbhttp.py
+++ b/tests/dumbhttp.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env python
 
 from __future__ import absolute_import
 



To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to