comparison tests/run-tests.py @ 25044:9de94acfde8a

run-tests: fix installation of hg by bytesifying more constants
author Augie Fackler <augie@google.com>
date Sun, 12 Apr 2015 16:14:07 -0400
parents 201823c50610
children 8a425c2eef5d
comparison
equal deleted inserted replaced
25043:facaceeb85ac 25044:9de94acfde8a
1954 """Install hg into the test environment. 1954 """Install hg into the test environment.
1955 1955
1956 This will also configure hg with the appropriate testing settings. 1956 This will also configure hg with the appropriate testing settings.
1957 """ 1957 """
1958 vlog("# Performing temporary installation of HG") 1958 vlog("# Performing temporary installation of HG")
1959 installerrs = os.path.join("tests", "install.err") 1959 installerrs = os.path.join(b"tests", b"install.err")
1960 compiler = '' 1960 compiler = ''
1961 if self.options.compiler: 1961 if self.options.compiler:
1962 compiler = '--compiler ' + self.options.compiler 1962 compiler = '--compiler ' + self.options.compiler
1963 if self.options.pure: 1963 if self.options.pure:
1964 pure = "--pure" 1964 pure = b"--pure"
1965 else: 1965 else:
1966 pure = "" 1966 pure = b""
1967 py3 = '' 1967 py3 = ''
1968 if sys.version_info[0] == 3:
1969 py3 = '--c2to3'
1970 1968
1971 # Run installer in hg root 1969 # Run installer in hg root
1972 script = os.path.realpath(sys.argv[0]) 1970 script = os.path.realpath(sys.argv[0])
1971 exe = sys.executable
1972 if sys.version_info[0] == 3:
1973 py3 = b'--c2to3'
1974 compiler = compiler.encode('utf-8')
1975 script = script.encode('utf-8')
1976 exe = exe.encode('utf-8')
1973 hgroot = os.path.dirname(os.path.dirname(script)) 1977 hgroot = os.path.dirname(os.path.dirname(script))
1974 self._hgroot = hgroot 1978 self._hgroot = hgroot
1975 os.chdir(hgroot) 1979 os.chdir(hgroot)
1976 nohome = '--home=""' 1980 nohome = b'--home=""'
1977 if os.name == 'nt': 1981 if os.name == 'nt':
1978 # The --home="" trick works only on OS where os.sep == '/' 1982 # The --home="" trick works only on OS where os.sep == '/'
1979 # because of a distutils convert_path() fast-path. Avoid it at 1983 # because of a distutils convert_path() fast-path. Avoid it at
1980 # least on Windows for now, deal with .pydistutils.cfg bugs 1984 # least on Windows for now, deal with .pydistutils.cfg bugs
1981 # when they happen. 1985 # when they happen.
1982 nohome = '' 1986 nohome = b''
1983 cmd = ('%(exe)s setup.py %(py3)s %(pure)s clean --all' 1987 cmd = (b'%(exe)s setup.py %(py3)s %(pure)s clean --all'
1984 ' build %(compiler)s --build-base="%(base)s"' 1988 b' build %(compiler)s --build-base="%(base)s"'
1985 ' install --force --prefix="%(prefix)s"' 1989 b' install --force --prefix="%(prefix)s"'
1986 ' --install-lib="%(libdir)s"' 1990 b' --install-lib="%(libdir)s"'
1987 ' --install-scripts="%(bindir)s" %(nohome)s >%(logfile)s 2>&1' 1991 b' --install-scripts="%(bindir)s" %(nohome)s >%(logfile)s 2>&1'
1988 % {'exe': sys.executable, 'py3': py3, 'pure': pure, 1992 % {b'exe': exe, b'py3': py3, b'pure': pure,
1989 'compiler': compiler, 1993 b'compiler': compiler,
1990 'base': os.path.join(self._hgtmp, b"build"), 1994 b'base': os.path.join(self._hgtmp, b"build"),
1991 'prefix': self._installdir, 'libdir': self._pythondir, 1995 b'prefix': self._installdir, b'libdir': self._pythondir,
1992 'bindir': self._bindir, 1996 b'bindir': self._bindir,
1993 'nohome': nohome, 'logfile': installerrs}) 1997 b'nohome': nohome, b'logfile': installerrs})
1994 1998
1995 # setuptools requires install directories to exist. 1999 # setuptools requires install directories to exist.
1996 def makedirs(p): 2000 def makedirs(p):
1997 try: 2001 try:
1998 os.makedirs(p) 2002 os.makedirs(p)
2028 f = open(os.path.join(self._bindir, 'hg'), 'wb') 2032 f = open(os.path.join(self._bindir, 'hg'), 'wb')
2029 for line in lines: 2033 for line in lines:
2030 f.write(line + '\n') 2034 f.write(line + '\n')
2031 f.close() 2035 f.close()
2032 2036
2033 hgbat = os.path.join(self._bindir, 'hg.bat') 2037 hgbat = os.path.join(self._bindir, b'hg.bat')
2034 if os.path.isfile(hgbat): 2038 if os.path.isfile(hgbat):
2035 # hg.bat expects to be put in bin/scripts while run-tests.py 2039 # hg.bat expects to be put in bin/scripts while run-tests.py
2036 # installation layout put it in bin/ directly. Fix it 2040 # installation layout put it in bin/ directly. Fix it
2037 f = open(hgbat, 'rb') 2041 f = open(hgbat, 'rb')
2038 data = f.read() 2042 data = f.read()
2039 f.close() 2043 f.close()
2040 if '"%~dp0..\python" "%~dp0hg" %*' in data: 2044 if b'"%~dp0..\python" "%~dp0hg" %*' in data:
2041 data = data.replace('"%~dp0..\python" "%~dp0hg" %*', 2045 data = data.replace(b'"%~dp0..\python" "%~dp0hg" %*',
2042 '"%~dp0python" "%~dp0hg" %*') 2046 b'"%~dp0python" "%~dp0hg" %*')
2043 f = open(hgbat, 'wb') 2047 f = open(hgbat, 'wb')
2044 f.write(data) 2048 f.write(data)
2045 f.close() 2049 f.close()
2046 else: 2050 else:
2047 print('WARNING: cannot fix hg.bat reference to python.exe') 2051 print('WARNING: cannot fix hg.bat reference to python.exe')
2069 if ((self._bindir == self._pythondir) and 2073 if ((self._bindir == self._pythondir) and
2070 (self._bindir != self._tmpbindir)): 2074 (self._bindir != self._tmpbindir)):
2071 # The pythondir has been inferred from --with-hg flag. 2075 # The pythondir has been inferred from --with-hg flag.
2072 # We cannot expect anything sensible here. 2076 # We cannot expect anything sensible here.
2073 return 2077 return
2074 expecthg = os.path.join(self._pythondir, 'mercurial') 2078 expecthg = os.path.join(self._pythondir, b'mercurial')
2075 actualhg = self._gethgpath() 2079 actualhg = self._gethgpath()
2076 if os.path.abspath(actualhg) != os.path.abspath(expecthg): 2080 if os.path.abspath(actualhg) != os.path.abspath(expecthg):
2077 sys.stderr.write('warning: %s with unexpected mercurial lib: %s\n' 2081 sys.stderr.write('warning: %s with unexpected mercurial lib: %s\n'
2078 ' (expected %s)\n' 2082 ' (expected %s)\n'
2079 % (verb, actualhg, expecthg)) 2083 % (verb, actualhg, expecthg))