tests/run-tests.py
changeset 39647 543a788eea2d
parent 39646 f3d1229555d9
child 39663 b6fa1f628bbe
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: