Mercurial > public > mercurial-scm > hg
comparison tests/run-tests.py @ 39647:543a788eea2d
py3: allow run-tests.py to run on Windows
This is now functional:
HGMODULEPOLICY=py py -3 run-tests.py --local test-help.t --pure --view bcompare
However, on this machine without a C compiler, it tries to load cext anyway, and
blows up. I haven't looked into why, other than to see that it does set the
environment variable. When the test exits though, I see it can't find
killdaemons.py, get-with-headers.py, etc.
I have no idea why these changes are needed, given that it runs on Linux. But
os.system() is insisting that it take a str, and subprocess.Popen() blows up
without str:
Errored test-help.t: Traceback (most recent call last):
File "run-tests.py", line 810, in run
self.runTest()
File "run-tests.py", line 858, in runTest
ret, out = self._run(env)
File "run-tests.py", line 1268, in _run
exitcode, output = self._runcommand(cmd, env)
File "run-tests.py", line 1141, in _runcommand
env=env)
File "C:\Program Files\Python37\lib\subprocess.py", line 756, in __init__
restore_signals, start_new_session)
File "C:\Program Files\Python37\lib\subprocess.py", line 1100, in _execute_child
args = list2cmdline(args)
File "C:\Program Files\Python37\lib\subprocess.py", line 511, in list2cmdline
needquote = (" " in arg) or ("\t" in arg) or not arg
TypeError: argument of type 'int' is not iterable
This is exactly how it crashes when trying to spin up a pager too. I left one
instance of os.system() unchanged in _installhg(), because it doesn't get there.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 15 Sep 2018 00:04:06 -0400 |
parents | f3d1229555d9 |
children | b6fa1f628bbe |
comparison
equal
deleted
inserted
replaced
39646:f3d1229555d9 | 39647:543a788eea2d |
---|---|
227 return False | 227 return False |
228 | 228 |
229 closefds = os.name == 'posix' | 229 closefds = os.name == 'posix' |
230 def Popen4(cmd, wd, timeout, env=None): | 230 def Popen4(cmd, wd, timeout, env=None): |
231 processlock.acquire() | 231 processlock.acquire() |
232 p = subprocess.Popen(cmd, shell=True, bufsize=-1, cwd=wd, env=env, | 232 p = subprocess.Popen(_strpath(cmd), shell=True, bufsize=-1, |
233 cwd=_strpath(wd), env=env, | |
233 close_fds=closefds, | 234 close_fds=closefds, |
234 stdin=subprocess.PIPE, stdout=subprocess.PIPE, | 235 stdin=subprocess.PIPE, stdout=subprocess.PIPE, |
235 stderr=subprocess.STDOUT) | 236 stderr=subprocess.STDOUT) |
236 processlock.release() | 237 processlock.release() |
237 | 238 |
986 def _escapepath(self, p): | 987 def _escapepath(self, p): |
987 if os.name == 'nt': | 988 if os.name == 'nt': |
988 return ( | 989 return ( |
989 (b''.join(c.isalpha() and b'[%s%s]' % (c.lower(), c.upper()) or | 990 (b''.join(c.isalpha() and b'[%s%s]' % (c.lower(), c.upper()) or |
990 c in b'/\\' and br'[/\\]' or c.isdigit() and c or b'\\' + c | 991 c in b'/\\' and br'[/\\]' or c.isdigit() and c or b'\\' + c |
991 for c in p)) | 992 for c in [p[i:i + 1] for i in range(len(p))])) |
992 ) | 993 ) |
993 else: | 994 else: |
994 return re.escape(p) | 995 return re.escape(p) |
995 | 996 |
996 def _localip(self): | 997 def _localip(self): |
1135 stderr). | 1136 stderr). |
1136 | 1137 |
1137 Return a tuple (exitcode, output). output is None in debug mode. | 1138 Return a tuple (exitcode, output). output is None in debug mode. |
1138 """ | 1139 """ |
1139 if self._debug: | 1140 if self._debug: |
1140 proc = subprocess.Popen(cmd, shell=True, cwd=self._testtmp, | 1141 proc = subprocess.Popen(_strpath(cmd), shell=True, |
1142 cwd=_strpath(self._testtmp), | |
1141 env=env) | 1143 env=env) |
1142 ret = proc.wait() | 1144 ret = proc.wait() |
1143 return (ret, None) | 1145 return (ret, None) |
1144 | 1146 |
1145 proc = Popen4(cmd, self._testtmp, self._timeout, env) | 1147 proc = Popen4(cmd, self._testtmp, self._timeout, env) |
1815 with iolock: | 1817 with iolock: |
1816 if self._options.nodiff: | 1818 if self._options.nodiff: |
1817 pass | 1819 pass |
1818 elif self._options.view: | 1820 elif self._options.view: |
1819 v = self._options.view | 1821 v = self._options.view |
1820 if PYTHON3: | 1822 os.system(r"%s %s %s" % |
1821 v = _bytespath(v) | 1823 (v, _strpath(test.refpath), _strpath(test.errpath))) |
1822 os.system(b"%s %s %s" % | |
1823 (v, test.refpath, test.errpath)) | |
1824 else: | 1824 else: |
1825 servefail, lines = getdiff(expected, got, | 1825 servefail, lines = getdiff(expected, got, |
1826 test.refpath, test.errpath) | 1826 test.refpath, test.errpath) |
1827 self.stream.write('\n') | 1827 self.stream.write('\n') |
1828 for line in lines: | 1828 for line in lines: |
2886 | 2886 |
2887 def _usecorrectpython(self): | 2887 def _usecorrectpython(self): |
2888 """Configure the environment to use the appropriate Python in tests.""" | 2888 """Configure the environment to use the appropriate Python in tests.""" |
2889 # Tests must use the same interpreter as us or bad things will happen. | 2889 # Tests must use the same interpreter as us or bad things will happen. |
2890 pyexename = sys.platform == 'win32' and b'python.exe' or b'python' | 2890 pyexename = sys.platform == 'win32' and b'python.exe' or b'python' |
2891 if getattr(os, 'symlink', None): | 2891 |
2892 # os.symlink() is a thing with py3 on Windows, but it requires | |
2893 # Administrator rights. | |
2894 if getattr(os, 'symlink', None) and os.name != 'nt': | |
2892 vlog("# Making python executable in test path a symlink to '%s'" % | 2895 vlog("# Making python executable in test path a symlink to '%s'" % |
2893 sys.executable) | 2896 sys.executable) |
2894 mypython = os.path.join(self._tmpbindir, pyexename) | 2897 mypython = os.path.join(self._tmpbindir, pyexename) |
2895 try: | 2898 try: |
2896 if os.readlink(mypython) == sys.executable: | 2899 if os.readlink(mypython) == sys.executable: |