Show More
@@ -30,7 +30,7 b' if sys.version_info > (3, 5, 0):' | |||||
30 | PYTHON3 = True |
|
30 | PYTHON3 = True | |
31 | xrange = range # we use xrange in one place, and we'd rather not use range |
|
31 | xrange = range # we use xrange in one place, and we'd rather not use range | |
32 |
|
32 | |||
33 |
def _bytes |
|
33 | def _sys2bytes(p): | |
34 | return p.encode('utf-8') |
|
34 | return p.encode('utf-8') | |
35 |
|
35 | |||
36 |
|
36 | |||
@@ -47,7 +47,7 b' else:' | |||||
47 | # bytestrings by default, so we don't have to do any extra |
|
47 | # bytestrings by default, so we don't have to do any extra | |
48 | # fiddling there. We define the wrapper functions anyway just to |
|
48 | # fiddling there. We define the wrapper functions anyway just to | |
49 | # help keep code consistent between platforms. |
|
49 | # help keep code consistent between platforms. | |
50 |
def _bytes |
|
50 | def _sys2bytes(p): | |
51 | return p |
|
51 | return p | |
52 |
|
52 | |||
53 |
|
53 | |||
@@ -107,7 +107,7 b' def watchman(args):' | |||||
107 | ] |
|
107 | ] | |
108 |
|
108 | |||
109 | envb = osenvironb.copy() |
|
109 | envb = osenvironb.copy() | |
110 |
envb[b'WATCHMAN_CONFIG_FILE'] = _bytes |
|
110 | envb[b'WATCHMAN_CONFIG_FILE'] = _sys2bytes(cfgfile) | |
111 | with open(clilogfile, 'wb') as f: |
|
111 | with open(clilogfile, 'wb') as f: | |
112 | proc = subprocess.Popen( |
|
112 | proc = subprocess.Popen( | |
113 | argv, env=envb, stdin=None, stdout=f, stderr=f |
|
113 | argv, env=envb, stdin=None, stdout=f, stderr=f | |
@@ -129,7 +129,7 b' def run():' | |||||
129 | args, runtestsargv = parser.parse_known_args() |
|
129 | args, runtestsargv = parser.parse_known_args() | |
130 |
|
130 | |||
131 | with watchman(args) as sockfile: |
|
131 | with watchman(args) as sockfile: | |
132 |
osenvironb[b'WATCHMAN_SOCK'] = _bytes |
|
132 | osenvironb[b'WATCHMAN_SOCK'] = _sys2bytes(sockfile) | |
133 | # Indicate to hghave that we're running with fsmonitor enabled. |
|
133 | # Indicate to hghave that we're running with fsmonitor enabled. | |
134 | osenvironb[b'HGFSMONITOR_TESTS'] = b'1' |
|
134 | osenvironb[b'HGFSMONITOR_TESTS'] = b'1' | |
135 |
|
135 |
@@ -29,12 +29,12 b" stderr = getattr(sys.stderr, 'buffer', s" | |||||
29 |
|
29 | |||
30 | if sys.version_info[0] >= 3: |
|
30 | if sys.version_info[0] >= 3: | |
31 |
|
31 | |||
32 |
def _bytes |
|
32 | def _sys2bytes(p): | |
33 | if p is None: |
|
33 | if p is None: | |
34 | return p |
|
34 | return p | |
35 | return p.encode('utf-8') |
|
35 | return p.encode('utf-8') | |
36 |
|
36 | |||
37 |
def _ |
|
37 | def _bytes2sys(p): | |
38 | if p is None: |
|
38 | if p is None: | |
39 | return p |
|
39 | return p | |
40 | return p.decode('utf-8') |
|
40 | return p.decode('utf-8') | |
@@ -42,10 +42,10 b' if sys.version_info[0] >= 3:' | |||||
42 |
|
42 | |||
43 | else: |
|
43 | else: | |
44 |
|
44 | |||
45 |
def _bytes |
|
45 | def _sys2bytes(p): | |
46 | return p |
|
46 | return p | |
47 |
|
47 | |||
48 | _strpath = _bytespath |
|
48 | _bytes2sys = _sys2bytes | |
49 |
|
49 | |||
50 |
|
50 | |||
51 | def check(name, desc): |
|
51 | def check(name, desc): | |
@@ -461,7 +461,7 b' def has_hardlink():' | |||||
461 | os.close(fh) |
|
461 | os.close(fh) | |
462 | name = tempfile.mktemp(dir='.', prefix=tempprefix) |
|
462 | name = tempfile.mktemp(dir='.', prefix=tempprefix) | |
463 | try: |
|
463 | try: | |
464 |
util.oslink(_bytes |
|
464 | util.oslink(_sys2bytes(fn), _sys2bytes(name)) | |
465 | os.unlink(name) |
|
465 | os.unlink(name) | |
466 | return True |
|
466 | return True | |
467 | except OSError: |
|
467 | except OSError: | |
@@ -1032,7 +1032,7 b' def has_black():' | |||||
1032 | version_regex = b'black, version ([0-9a-b.]+)' |
|
1032 | version_regex = b'black, version ([0-9a-b.]+)' | |
1033 | version = matchoutput(blackcmd, version_regex) |
|
1033 | version = matchoutput(blackcmd, version_regex) | |
1034 | sv = distutils.version.StrictVersion |
|
1034 | sv = distutils.version.StrictVersion | |
1035 |
return version and sv(_ |
|
1035 | return version and sv(_bytes2sys(version.group(1))) >= sv('19.10b0') | |
1036 |
|
1036 | |||
1037 |
|
1037 | |||
1038 | @check('pytype', 'the pytype type checker') |
|
1038 | @check('pytype', 'the pytype type checker') | |
@@ -1040,7 +1040,7 b' def has_pytype():' | |||||
1040 | pytypecmd = 'pytype --version' |
|
1040 | pytypecmd = 'pytype --version' | |
1041 | version = matchoutput(pytypecmd, b'[0-9a-b.]+') |
|
1041 | version = matchoutput(pytypecmd, b'[0-9a-b.]+') | |
1042 | sv = distutils.version.StrictVersion |
|
1042 | sv = distutils.version.StrictVersion | |
1043 |
return version and sv(_ |
|
1043 | return version and sv(_bytes2sys(version.group(0))) >= sv('2019.10.17') | |
1044 |
|
1044 | |||
1045 |
|
1045 | |||
1046 | @check("rustfmt", "rustfmt tool") |
|
1046 | @check("rustfmt", "rustfmt tool") |
@@ -143,12 +143,12 b' if sys.version_info > (3, 5, 0):' | |||||
143 | PYTHON3 = True |
|
143 | PYTHON3 = True | |
144 | xrange = range # we use xrange in one place, and we'd rather not use range |
|
144 | xrange = range # we use xrange in one place, and we'd rather not use range | |
145 |
|
145 | |||
146 |
def _bytes |
|
146 | def _sys2bytes(p): | |
147 | if p is None: |
|
147 | if p is None: | |
148 | return p |
|
148 | return p | |
149 | return p.encode('utf-8') |
|
149 | return p.encode('utf-8') | |
150 |
|
150 | |||
151 |
def _ |
|
151 | def _bytes2sys(p): | |
152 | if p is None: |
|
152 | if p is None: | |
153 | return p |
|
153 | return p | |
154 | return p.decode('utf-8') |
|
154 | return p.decode('utf-8') | |
@@ -165,34 +165,34 b' if sys.version_info > (3, 5, 0):' | |||||
165 | self._strenv = strenv |
|
165 | self._strenv = strenv | |
166 |
|
166 | |||
167 | def __getitem__(self, k): |
|
167 | def __getitem__(self, k): | |
168 |
v = self._strenv.__getitem__(_ |
|
168 | v = self._strenv.__getitem__(_bytes2sys(k)) | |
169 |
return _bytes |
|
169 | return _sys2bytes(v) | |
170 |
|
170 | |||
171 | def __setitem__(self, k, v): |
|
171 | def __setitem__(self, k, v): | |
172 |
self._strenv.__setitem__(_ |
|
172 | self._strenv.__setitem__(_bytes2sys(k), _bytes2sys(v)) | |
173 |
|
173 | |||
174 | def __delitem__(self, k): |
|
174 | def __delitem__(self, k): | |
175 |
self._strenv.__delitem__(_ |
|
175 | self._strenv.__delitem__(_bytes2sys(k)) | |
176 |
|
176 | |||
177 | def __contains__(self, k): |
|
177 | def __contains__(self, k): | |
178 |
return self._strenv.__contains__(_ |
|
178 | return self._strenv.__contains__(_bytes2sys(k)) | |
179 |
|
179 | |||
180 | def __iter__(self): |
|
180 | def __iter__(self): | |
181 |
return iter([_bytes |
|
181 | return iter([_sys2bytes(k) for k in iter(self._strenv)]) | |
182 |
|
182 | |||
183 | def get(self, k, default=None): |
|
183 | def get(self, k, default=None): | |
184 |
v = self._strenv.get(_ |
|
184 | v = self._strenv.get(_bytes2sys(k), _bytes2sys(default)) | |
185 |
return _bytes |
|
185 | return _sys2bytes(v) | |
186 |
|
186 | |||
187 | def pop(self, k, default=None): |
|
187 | def pop(self, k, default=None): | |
188 |
v = self._strenv.pop(_ |
|
188 | v = self._strenv.pop(_bytes2sys(k), _bytes2sys(default)) | |
189 |
return _bytes |
|
189 | return _sys2bytes(v) | |
190 |
|
190 | |||
191 | osenvironb = environbytes(os.environ) |
|
191 | osenvironb = environbytes(os.environ) | |
192 |
|
192 | |||
193 | getcwdb = getattr(os, 'getcwdb') |
|
193 | getcwdb = getattr(os, 'getcwdb') | |
194 | if not getcwdb or os.name == 'nt': |
|
194 | if not getcwdb or os.name == 'nt': | |
195 |
getcwdb = lambda: _bytes |
|
195 | getcwdb = lambda: _sys2bytes(os.getcwd()) | |
196 |
|
196 | |||
197 | elif sys.version_info >= (3, 0, 0): |
|
197 | elif sys.version_info >= (3, 0, 0): | |
198 | print( |
|
198 | print( | |
@@ -207,10 +207,10 b' else:' | |||||
207 | # bytestrings by default, so we don't have to do any extra |
|
207 | # bytestrings by default, so we don't have to do any extra | |
208 | # fiddling there. We define the wrapper functions anyway just to |
|
208 | # fiddling there. We define the wrapper functions anyway just to | |
209 | # help keep code consistent between platforms. |
|
209 | # help keep code consistent between platforms. | |
210 |
def _bytes |
|
210 | def _sys2bytes(p): | |
211 | return p |
|
211 | return p | |
212 |
|
212 | |||
213 | _strpath = _bytespath |
|
213 | _bytes2sys = _sys2bytes | |
214 | osenvironb = os.environ |
|
214 | osenvironb = os.environ | |
215 | getcwdb = os.getcwd |
|
215 | getcwdb = os.getcwd | |
216 |
|
216 | |||
@@ -274,10 +274,10 b" closefds = os.name == 'posix'" | |||||
274 | def Popen4(cmd, wd, timeout, env=None): |
|
274 | def Popen4(cmd, wd, timeout, env=None): | |
275 | processlock.acquire() |
|
275 | processlock.acquire() | |
276 | p = subprocess.Popen( |
|
276 | p = subprocess.Popen( | |
277 |
_ |
|
277 | _bytes2sys(cmd), | |
278 | shell=True, |
|
278 | shell=True, | |
279 | bufsize=-1, |
|
279 | bufsize=-1, | |
280 |
cwd=_ |
|
280 | cwd=_bytes2sys(wd), | |
281 | env=env, |
|
281 | env=env, | |
282 | close_fds=closefds, |
|
282 | close_fds=closefds, | |
283 | stdin=subprocess.PIPE, |
|
283 | stdin=subprocess.PIPE, | |
@@ -315,7 +315,7 b" elif os.environ.get('PYTHON'):" | |||||
315 | else: |
|
315 | else: | |
316 | raise AssertionError('Could not find Python interpreter') |
|
316 | raise AssertionError('Could not find Python interpreter') | |
317 |
|
317 | |||
318 |
PYTHON = _bytes |
|
318 | PYTHON = _sys2bytes(sysexecutable.replace('\\', '/')) | |
319 | IMPL_PATH = b'PYTHONPATH' |
|
319 | IMPL_PATH = b'PYTHONPATH' | |
320 | if 'java' in sys.platform: |
|
320 | if 'java' in sys.platform: | |
321 | IMPL_PATH = b'JYTHONPATH' |
|
321 | IMPL_PATH = b'JYTHONPATH' | |
@@ -640,7 +640,7 b' def parseargs(args, parser):' | |||||
640 | if options.local: |
|
640 | if options.local: | |
641 | if options.with_hg or options.with_chg: |
|
641 | if options.with_hg or options.with_chg: | |
642 | parser.error('--local cannot be used with --with-hg or --with-chg') |
|
642 | parser.error('--local cannot be used with --with-hg or --with-chg') | |
643 |
testdir = os.path.dirname(_bytes |
|
643 | testdir = os.path.dirname(_sys2bytes(canonpath(sys.argv[0]))) | |
644 | reporootdir = os.path.dirname(testdir) |
|
644 | reporootdir = os.path.dirname(testdir) | |
645 | pathandattrs = [(b'hg', 'with_hg')] |
|
645 | pathandattrs = [(b'hg', 'with_hg')] | |
646 | if options.chg: |
|
646 | if options.chg: | |
@@ -652,10 +652,10 b' def parseargs(args, parser):' | |||||
652 | '--local specified, but %r not found or ' |
|
652 | '--local specified, but %r not found or ' | |
653 | 'not executable' % binpath |
|
653 | 'not executable' % binpath | |
654 | ) |
|
654 | ) | |
655 |
setattr(options, attr, _ |
|
655 | setattr(options, attr, _bytes2sys(binpath)) | |
656 |
|
656 | |||
657 | if options.with_hg: |
|
657 | if options.with_hg: | |
658 |
options.with_hg = canonpath(_bytes |
|
658 | options.with_hg = canonpath(_sys2bytes(options.with_hg)) | |
659 | if not ( |
|
659 | if not ( | |
660 | os.path.isfile(options.with_hg) |
|
660 | os.path.isfile(options.with_hg) | |
661 | and os.access(options.with_hg, os.X_OK) |
|
661 | and os.access(options.with_hg, os.X_OK) | |
@@ -669,7 +669,7 b' def parseargs(args, parser):' | |||||
669 | parser.error('chg does not work on %s' % os.name) |
|
669 | parser.error('chg does not work on %s' % os.name) | |
670 | if options.with_chg: |
|
670 | if options.with_chg: | |
671 | options.chg = False # no installation to temporary location |
|
671 | options.chg = False # no installation to temporary location | |
672 |
options.with_chg = canonpath(_bytes |
|
672 | options.with_chg = canonpath(_sys2bytes(options.with_chg)) | |
673 | if not ( |
|
673 | if not ( | |
674 | os.path.isfile(options.with_chg) |
|
674 | os.path.isfile(options.with_chg) | |
675 | and os.access(options.with_chg, os.X_OK) |
|
675 | and os.access(options.with_chg, os.X_OK) | |
@@ -942,7 +942,7 b' class Test(unittest.TestCase):' | |||||
942 | slowtimeout = defaults['slowtimeout'] |
|
942 | slowtimeout = defaults['slowtimeout'] | |
943 | self.path = path |
|
943 | self.path = path | |
944 | self.bname = os.path.basename(path) |
|
944 | self.bname = os.path.basename(path) | |
945 |
self.name = _ |
|
945 | self.name = _bytes2sys(self.bname) | |
946 | self._testdir = os.path.dirname(path) |
|
946 | self._testdir = os.path.dirname(path) | |
947 | self._outputdir = outputdir |
|
947 | self._outputdir = outputdir | |
948 | self._tmpname = os.path.basename(path) |
|
948 | self._tmpname = os.path.basename(path) | |
@@ -956,7 +956,7 b' class Test(unittest.TestCase):' | |||||
956 | self._slowtimeout = slowtimeout |
|
956 | self._slowtimeout = slowtimeout | |
957 | self._startport = startport |
|
957 | self._startport = startport | |
958 | self._extraconfigopts = extraconfigopts or [] |
|
958 | self._extraconfigopts = extraconfigopts or [] | |
959 |
self._shell = _bytes |
|
959 | self._shell = _sys2bytes(shell) | |
960 | self._hgcommand = hgcommand or b'hg' |
|
960 | self._hgcommand = hgcommand or b'hg' | |
961 | self._usechg = usechg |
|
961 | self._usechg = usechg | |
962 | self._useipv6 = useipv6 |
|
962 | self._useipv6 = useipv6 | |
@@ -1268,7 +1268,7 b' class Test(unittest.TestCase):' | |||||
1268 | environment.""" |
|
1268 | environment.""" | |
1269 | # Put the restoreenv script inside self._threadtmp |
|
1269 | # Put the restoreenv script inside self._threadtmp | |
1270 | scriptpath = os.path.join(self._threadtmp, b'restoreenv.sh') |
|
1270 | scriptpath = os.path.join(self._threadtmp, b'restoreenv.sh') | |
1271 |
testenv['HGTEST_RESTOREENV'] = _ |
|
1271 | testenv['HGTEST_RESTOREENV'] = _bytes2sys(scriptpath) | |
1272 |
|
1272 | |||
1273 | # Only restore environment variable names that the shell allows |
|
1273 | # Only restore environment variable names that the shell allows | |
1274 | # us to export. |
|
1274 | # us to export. | |
@@ -1302,15 +1302,15 b' class Test(unittest.TestCase):' | |||||
1302 | env = os.environ.copy() |
|
1302 | env = os.environ.copy() | |
1303 | env['PYTHONUSERBASE'] = sysconfig.get_config_var('userbase') or '' |
|
1303 | env['PYTHONUSERBASE'] = sysconfig.get_config_var('userbase') or '' | |
1304 | env['HGEMITWARNINGS'] = '1' |
|
1304 | env['HGEMITWARNINGS'] = '1' | |
1305 |
env['TESTTMP'] = _ |
|
1305 | env['TESTTMP'] = _bytes2sys(self._testtmp) | |
1306 | env['TESTNAME'] = self.name |
|
1306 | env['TESTNAME'] = self.name | |
1307 |
env['HOME'] = _ |
|
1307 | env['HOME'] = _bytes2sys(self._testtmp) | |
1308 | # This number should match portneeded in _getport |
|
1308 | # This number should match portneeded in _getport | |
1309 | for port in xrange(3): |
|
1309 | for port in xrange(3): | |
1310 | # This list should be parallel to _portmap in _getreplacements |
|
1310 | # This list should be parallel to _portmap in _getreplacements | |
1311 | defineport(port) |
|
1311 | defineport(port) | |
1312 |
env["HGRCPATH"] = _ |
|
1312 | env["HGRCPATH"] = _bytes2sys(os.path.join(self._threadtmp, b'.hgrc')) | |
1313 |
env["DAEMON_PIDS"] = _ |
|
1313 | env["DAEMON_PIDS"] = _bytes2sys( | |
1314 | os.path.join(self._threadtmp, b'daemon.pids') |
|
1314 | os.path.join(self._threadtmp, b'daemon.pids') | |
1315 | ) |
|
1315 | ) | |
1316 | env["HGEDITOR"] = ( |
|
1316 | env["HGEDITOR"] = ( | |
@@ -1342,7 +1342,7 b' class Test(unittest.TestCase):' | |||||
1342 |
|
1342 | |||
1343 | # LOCALIP could be ::1 or 127.0.0.1. Useful for tests that require raw |
|
1343 | # LOCALIP could be ::1 or 127.0.0.1. Useful for tests that require raw | |
1344 | # IP addresses. |
|
1344 | # IP addresses. | |
1345 |
env['LOCALIP'] = _ |
|
1345 | env['LOCALIP'] = _bytes2sys(self._localip()) | |
1346 |
|
1346 | |||
1347 | # This has the same effect as Py_LegacyWindowsStdioFlag in exewrapper.c, |
|
1347 | # This has the same effect as Py_LegacyWindowsStdioFlag in exewrapper.c, | |
1348 | # but this is needed for testing python instances like dummyssh, |
|
1348 | # but this is needed for testing python instances like dummyssh, | |
@@ -1451,7 +1451,10 b' class Test(unittest.TestCase):' | |||||
1451 | """ |
|
1451 | """ | |
1452 | if self._debug: |
|
1452 | if self._debug: | |
1453 | proc = subprocess.Popen( |
|
1453 | proc = subprocess.Popen( | |
1454 | _strpath(cmd), shell=True, cwd=_strpath(self._testtmp), env=env |
|
1454 | _bytes2sys(cmd), | |
|
1455 | shell=True, | |||
|
1456 | cwd=_bytes2sys(self._testtmp), | |||
|
1457 | env=env, | |||
1455 | ) |
|
1458 | ) | |
1456 | ret = proc.wait() |
|
1459 | ret = proc.wait() | |
1457 | return (ret, None) |
|
1460 | return (ret, None) | |
@@ -1561,7 +1564,7 b' class TTest(Test):' | |||||
1561 | super(TTest, self).__init__(path, *args, **kwds) |
|
1564 | super(TTest, self).__init__(path, *args, **kwds) | |
1562 | if case: |
|
1565 | if case: | |
1563 | casepath = b'#'.join(case) |
|
1566 | casepath = b'#'.join(case) | |
1564 |
self.name = '%s#%s' % (self.name, _ |
|
1567 | self.name = '%s#%s' % (self.name, _bytes2sys(casepath)) | |
1565 | self.errpath = b'%s#%s.err' % (self.errpath[:-4], casepath) |
|
1568 | self.errpath = b'%s#%s.err' % (self.errpath[:-4], casepath) | |
1566 | self._tmpname += b'-%s' % casepath |
|
1569 | self._tmpname += b'-%s' % casepath | |
1567 | self._have = {} |
|
1570 | self._have = {} | |
@@ -1612,7 +1615,7 b' class TTest(Test):' | |||||
1612 | return self._have.get(allreqs) |
|
1615 | return self._have.get(allreqs) | |
1613 |
|
1616 | |||
1614 | # TODO do something smarter when all other uses of hghave are gone. |
|
1617 | # TODO do something smarter when all other uses of hghave are gone. | |
1615 |
runtestdir = os.path.abspath(os.path.dirname(_bytes |
|
1618 | runtestdir = os.path.abspath(os.path.dirname(_sys2bytes(__file__))) | |
1616 | tdir = runtestdir.replace(b'\\', b'/') |
|
1619 | tdir = runtestdir.replace(b'\\', b'/') | |
1617 | proc = Popen4( |
|
1620 | proc = Popen4( | |
1618 | b'%s -c "%s/hghave %s"' % (self._shell, tdir, allreqs), |
|
1621 | b'%s -c "%s/hghave %s"' % (self._shell, tdir, allreqs), | |
@@ -2199,7 +2202,7 b' class TestResult(unittest._TextTestResul' | |||||
2199 | v = self._options.view |
|
2202 | v = self._options.view | |
2200 | subprocess.call( |
|
2203 | subprocess.call( | |
2201 | r'"%s" "%s" "%s"' |
|
2204 | r'"%s" "%s" "%s"' | |
2202 |
% (v, _ |
|
2205 | % (v, _bytes2sys(test.refpath), _bytes2sys(test.errpath)), | |
2203 | shell=True, |
|
2206 | shell=True, | |
2204 | ) |
|
2207 | ) | |
2205 | else: |
|
2208 | else: | |
@@ -2688,7 +2691,7 b' class TextTestRunner(unittest.TextTestRu' | |||||
2688 | opts = '' |
|
2691 | opts = '' | |
2689 | withhg = self._runner.options.with_hg |
|
2692 | withhg = self._runner.options.with_hg | |
2690 | if withhg: |
|
2693 | if withhg: | |
2691 |
opts += ' --with-hg=%s ' % shellquote(_ |
|
2694 | opts += ' --with-hg=%s ' % shellquote(_bytes2sys(withhg)) | |
2692 | rtc = '%s %s %s %s' % (sysexecutable, sys.argv[0], opts, test) |
|
2695 | rtc = '%s %s %s %s' % (sysexecutable, sys.argv[0], opts, test) | |
2693 | data = pread(bisectcmd + ['--command', rtc]) |
|
2696 | data = pread(bisectcmd + ['--command', rtc]) | |
2694 | m = re.search( |
|
2697 | m = re.search( | |
@@ -2930,7 +2933,7 b' class TestRunner(object):' | |||||
2930 | try: |
|
2933 | try: | |
2931 | parser = parser or getparser() |
|
2934 | parser = parser or getparser() | |
2932 | options = parseargs(args, parser) |
|
2935 | options = parseargs(args, parser) | |
2933 |
tests = [_bytes |
|
2936 | tests = [_sys2bytes(a) for a in options.tests] | |
2934 | if options.test_list is not None: |
|
2937 | if options.test_list is not None: | |
2935 | for listfile in options.test_list: |
|
2938 | for listfile in options.test_list: | |
2936 | with open(listfile, 'rb') as f: |
|
2939 | with open(listfile, 'rb') as f: | |
@@ -2962,7 +2965,7 b' class TestRunner(object):' | |||||
2962 | testdir = os.path.join(testdir, pathname) |
|
2965 | testdir = os.path.join(testdir, pathname) | |
2963 | self._testdir = osenvironb[b'TESTDIR'] = testdir |
|
2966 | self._testdir = osenvironb[b'TESTDIR'] = testdir | |
2964 | if self.options.outputdir: |
|
2967 | if self.options.outputdir: | |
2965 |
self._outputdir = canonpath(_bytes |
|
2968 | self._outputdir = canonpath(_sys2bytes(self.options.outputdir)) | |
2966 | else: |
|
2969 | else: | |
2967 | self._outputdir = getcwdb() |
|
2970 | self._outputdir = getcwdb() | |
2968 | if testdescs and pathname: |
|
2971 | if testdescs and pathname: | |
@@ -2979,7 +2982,7 b' class TestRunner(object):' | |||||
2979 |
|
2982 | |||
2980 | if self.options.tmpdir: |
|
2983 | if self.options.tmpdir: | |
2981 | self.options.keep_tmpdir = True |
|
2984 | self.options.keep_tmpdir = True | |
2982 |
tmpdir = _bytes |
|
2985 | tmpdir = _sys2bytes(self.options.tmpdir) | |
2983 | if os.path.exists(tmpdir): |
|
2986 | if os.path.exists(tmpdir): | |
2984 | # Meaning of tmpdir has changed since 1.3: we used to create |
|
2987 | # Meaning of tmpdir has changed since 1.3: we used to create | |
2985 | # HGTMP inside tmpdir; now HGTMP is tmpdir. So fail if |
|
2988 | # HGTMP inside tmpdir; now HGTMP is tmpdir. So fail if | |
@@ -3008,7 +3011,7 b' class TestRunner(object):' | |||||
3008 | os.makedirs(self._tmpbindir) |
|
3011 | os.makedirs(self._tmpbindir) | |
3009 |
|
3012 | |||
3010 | normbin = os.path.normpath(os.path.abspath(whg)) |
|
3013 | normbin = os.path.normpath(os.path.abspath(whg)) | |
3011 |
normbin = normbin.replace(_bytes |
|
3014 | normbin = normbin.replace(_sys2bytes(os.sep), b'/') | |
3012 |
|
3015 | |||
3013 | # Other Python scripts in the test harness need to |
|
3016 | # Other Python scripts in the test harness need to | |
3014 | # `import mercurial`. If `hg` is a Python script, we assume |
|
3017 | # `import mercurial`. If `hg` is a Python script, we assume | |
@@ -3057,11 +3060,11 b' class TestRunner(object):' | |||||
3057 | osenvironb[b"BINDIR"] = self._bindir |
|
3060 | osenvironb[b"BINDIR"] = self._bindir | |
3058 | osenvironb[b"PYTHON"] = PYTHON |
|
3061 | osenvironb[b"PYTHON"] = PYTHON | |
3059 |
|
3062 | |||
3060 |
fileb = _bytes |
|
3063 | fileb = _sys2bytes(__file__) | |
3061 | runtestdir = os.path.abspath(os.path.dirname(fileb)) |
|
3064 | runtestdir = os.path.abspath(os.path.dirname(fileb)) | |
3062 | osenvironb[b'RUNTESTDIR'] = runtestdir |
|
3065 | osenvironb[b'RUNTESTDIR'] = runtestdir | |
3063 | if PYTHON3: |
|
3066 | if PYTHON3: | |
3064 |
sepb = _bytes |
|
3067 | sepb = _sys2bytes(os.pathsep) | |
3065 | else: |
|
3068 | else: | |
3066 | sepb = os.pathsep |
|
3069 | sepb = os.pathsep | |
3067 | path = [self._bindir, runtestdir] + osenvironb[b"PATH"].split(sepb) |
|
3070 | path = [self._bindir, runtestdir] + osenvironb[b"PATH"].split(sepb) | |
@@ -3121,14 +3124,14 b' class TestRunner(object):' | |||||
3121 | 'extensions.logexceptions=%s' % logexceptions.decode('utf-8') |
|
3124 | 'extensions.logexceptions=%s' % logexceptions.decode('utf-8') | |
3122 | ) |
|
3125 | ) | |
3123 |
|
3126 | |||
3124 |
vlog("# Using TESTDIR", _ |
|
3127 | vlog("# Using TESTDIR", _bytes2sys(self._testdir)) | |
3125 |
vlog("# Using RUNTESTDIR", _ |
|
3128 | vlog("# Using RUNTESTDIR", _bytes2sys(osenvironb[b'RUNTESTDIR'])) | |
3126 |
vlog("# Using HGTMP", _ |
|
3129 | vlog("# Using HGTMP", _bytes2sys(self._hgtmp)) | |
3127 | vlog("# Using PATH", os.environ["PATH"]) |
|
3130 | vlog("# Using PATH", os.environ["PATH"]) | |
3128 | vlog( |
|
3131 | vlog( | |
3129 |
"# Using", _ |
|
3132 | "# Using", _bytes2sys(IMPL_PATH), _bytes2sys(osenvironb[IMPL_PATH]), | |
3130 | ) |
|
3133 | ) | |
3131 |
vlog("# Writing to directory", _ |
|
3134 | vlog("# Writing to directory", _bytes2sys(self._outputdir)) | |
3132 |
|
3135 | |||
3133 | try: |
|
3136 | try: | |
3134 | return self._runtests(testdescs) or 0 |
|
3137 | return self._runtests(testdescs) or 0 | |
@@ -3146,7 +3149,7 b' class TestRunner(object):' | |||||
3146 | if self.options.changed: |
|
3149 | if self.options.changed: | |
3147 | proc = Popen4( |
|
3150 | proc = Popen4( | |
3148 | b'hg st --rev "%s" -man0 .' |
|
3151 | b'hg st --rev "%s" -man0 .' | |
3149 |
% _bytes |
|
3152 | % _sys2bytes(self.options.changed), | |
3150 | None, |
|
3153 | None, | |
3151 | 0, |
|
3154 | 0, | |
3152 | ) |
|
3155 | ) | |
@@ -3366,7 +3369,7 b' class TestRunner(object):' | |||||
3366 | if self.options.keep_tmpdir: |
|
3369 | if self.options.keep_tmpdir: | |
3367 | return |
|
3370 | return | |
3368 |
|
3371 | |||
3369 |
vlog("# Cleaning up HGTMP", _ |
|
3372 | vlog("# Cleaning up HGTMP", _bytes2sys(self._hgtmp)) | |
3370 | shutil.rmtree(self._hgtmp, True) |
|
3373 | shutil.rmtree(self._hgtmp, True) | |
3371 | for f in self._createdfiles: |
|
3374 | for f in self._createdfiles: | |
3372 | try: |
|
3375 | try: | |
@@ -3434,9 +3437,9 b' class TestRunner(object):' | |||||
3434 | script = os.path.realpath(sys.argv[0]) |
|
3437 | script = os.path.realpath(sys.argv[0]) | |
3435 | exe = sysexecutable |
|
3438 | exe = sysexecutable | |
3436 | if PYTHON3: |
|
3439 | if PYTHON3: | |
3437 |
compiler = _bytes |
|
3440 | compiler = _sys2bytes(compiler) | |
3438 |
script = _bytes |
|
3441 | script = _sys2bytes(script) | |
3439 |
exe = _bytes |
|
3442 | exe = _sys2bytes(exe) | |
3440 | hgroot = os.path.dirname(os.path.dirname(script)) |
|
3443 | hgroot = os.path.dirname(os.path.dirname(script)) | |
3441 | self._hgroot = hgroot |
|
3444 | self._hgroot = hgroot | |
3442 | os.chdir(hgroot) |
|
3445 | os.chdir(hgroot) | |
@@ -3478,7 +3481,7 b' class TestRunner(object):' | |||||
3478 | makedirs(self._bindir) |
|
3481 | makedirs(self._bindir) | |
3479 |
|
3482 | |||
3480 | vlog("# Running", cmd.decode("utf-8")) |
|
3483 | vlog("# Running", cmd.decode("utf-8")) | |
3481 |
if subprocess.call(_ |
|
3484 | if subprocess.call(_bytes2sys(cmd), shell=True) == 0: | |
3482 | if not self.options.verbose: |
|
3485 | if not self.options.verbose: | |
3483 | try: |
|
3486 | try: | |
3484 | os.remove(installerrs) |
|
3487 | os.remove(installerrs) | |
@@ -3558,7 +3561,7 b' class TestRunner(object):' | |||||
3558 | cmd = b'"%s" -c "import mercurial; print (mercurial.__path__[0])"' |
|
3561 | cmd = b'"%s" -c "import mercurial; print (mercurial.__path__[0])"' | |
3559 | cmd = cmd % PYTHON |
|
3562 | cmd = cmd % PYTHON | |
3560 | if PYTHON3: |
|
3563 | if PYTHON3: | |
3561 |
cmd = _ |
|
3564 | cmd = _bytes2sys(cmd) | |
3562 |
|
3565 | |||
3563 | p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) |
|
3566 | p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) | |
3564 | out, err = p.communicate() |
|
3567 | out, err = p.communicate() | |
@@ -3604,33 +3607,33 b' class TestRunner(object):' | |||||
3604 | # chdir is the easiest way to get short, relative paths in the |
|
3607 | # chdir is the easiest way to get short, relative paths in the | |
3605 | # output. |
|
3608 | # output. | |
3606 | os.chdir(self._hgroot) |
|
3609 | os.chdir(self._hgroot) | |
3607 |
covdir = os.path.join(_ |
|
3610 | covdir = os.path.join(_bytes2sys(self._installdir), '..', 'coverage') | |
3608 | cov = coverage(data_file=os.path.join(covdir, 'cov')) |
|
3611 | cov = coverage(data_file=os.path.join(covdir, 'cov')) | |
3609 |
|
3612 | |||
3610 | # Map install directory paths back to source directory. |
|
3613 | # Map install directory paths back to source directory. | |
3611 |
cov.config.paths['srcdir'] = ['.', _ |
|
3614 | cov.config.paths['srcdir'] = ['.', _bytes2sys(self._pythondir)] | |
3612 |
|
3615 | |||
3613 | cov.combine() |
|
3616 | cov.combine() | |
3614 |
|
3617 | |||
3615 | omit = [ |
|
3618 | omit = [ | |
3616 |
_ |
|
3619 | _bytes2sys(os.path.join(x, b'*')) | |
3617 | for x in [self._bindir, self._testdir] |
|
3620 | for x in [self._bindir, self._testdir] | |
3618 | ] |
|
3621 | ] | |
3619 | cov.report(ignore_errors=True, omit=omit) |
|
3622 | cov.report(ignore_errors=True, omit=omit) | |
3620 |
|
3623 | |||
3621 | if self.options.htmlcov: |
|
3624 | if self.options.htmlcov: | |
3622 |
htmldir = os.path.join(_ |
|
3625 | htmldir = os.path.join(_bytes2sys(self._outputdir), 'htmlcov') | |
3623 | cov.html_report(directory=htmldir, omit=omit) |
|
3626 | cov.html_report(directory=htmldir, omit=omit) | |
3624 | if self.options.annotate: |
|
3627 | if self.options.annotate: | |
3625 |
adir = os.path.join(_ |
|
3628 | adir = os.path.join(_bytes2sys(self._outputdir), 'annotated') | |
3626 | if not os.path.isdir(adir): |
|
3629 | if not os.path.isdir(adir): | |
3627 | os.mkdir(adir) |
|
3630 | os.mkdir(adir) | |
3628 | cov.annotate(directory=adir, omit=omit) |
|
3631 | cov.annotate(directory=adir, omit=omit) | |
3629 |
|
3632 | |||
3630 | def _findprogram(self, program): |
|
3633 | def _findprogram(self, program): | |
3631 | """Search PATH for a executable program""" |
|
3634 | """Search PATH for a executable program""" | |
3632 |
dpb = _bytes |
|
3635 | dpb = _sys2bytes(os.defpath) | |
3633 |
sepb = _bytes |
|
3636 | sepb = _sys2bytes(os.pathsep) | |
3634 | for p in osenvironb.get(b'PATH', dpb).split(sepb): |
|
3637 | for p in osenvironb.get(b'PATH', dpb).split(sepb): | |
3635 | name = os.path.join(p, program) |
|
3638 | name = os.path.join(p, program) | |
3636 | if os.name == 'nt' or os.access(name, os.X_OK): |
|
3639 | if os.name == 'nt' or os.access(name, os.X_OK): | |
@@ -3645,7 +3648,7 b' class TestRunner(object):' | |||||
3645 | found = self._findprogram(p) |
|
3648 | found = self._findprogram(p) | |
3646 | p = p.decode("utf-8") |
|
3649 | p = p.decode("utf-8") | |
3647 | if found: |
|
3650 | if found: | |
3648 |
vlog("# Found prerequisite", p, "at", _ |
|
3651 | vlog("# Found prerequisite", p, "at", _bytes2sys(found)) | |
3649 | else: |
|
3652 | else: | |
3650 | print("WARNING: Did not find prerequisite tool: %s " % p) |
|
3653 | print("WARNING: Did not find prerequisite tool: %s " % p) | |
3651 |
|
3654 |
General Comments 0
You need to be logged in to leave comments.
Login now