Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG35180ade80c1: tests: fix bytes/str issues in run-tests.py caught by python3
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | tests/run-tests.py (10 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Augie Fackler | Aug 6 2018, 5:19 PM |
def __init__(self, path, *args, **kwds): | def __init__(self, path, *args, **kwds): | ||||
# accept an extra "case" parameter | # accept an extra "case" parameter | ||||
case = kwds.pop('case', []) | case = kwds.pop('case', []) | ||||
self._case = case | self._case = case | ||||
self._allcases = {x for y in parsettestcases(path) for x in y} | self._allcases = {x for y in parsettestcases(path) for x in y} | ||||
super(TTest, self).__init__(path, *args, **kwds) | super(TTest, self).__init__(path, *args, **kwds) | ||||
if case: | if case: | ||||
casepath = _strpath('#'.join(case)) | casepath = b'#'.join(case) | ||||
self.name = '%s#%s' % (self.name, casepath) | self.name = '%s#%s' % (self.name, _strpath(casepath)) | ||||
self.errpath = b'%s#%s.err' % (self.errpath[:-4], casepath) | self.errpath = b'%s#%s.err' % (self.errpath[:-4], casepath) | ||||
self._tmpname += b'-%s' % casepath | self._tmpname += b'-%s' % casepath | ||||
self._have = {} | self._have = {} | ||||
@property | @property | ||||
def refpath(self): | def refpath(self): | ||||
return os.path.join(self._testdir, self.bname) | return os.path.join(self._testdir, self.bname) | ||||
if self._debug: | if self._debug: | ||||
script.append(b'set -x\n') | script.append(b'set -x\n') | ||||
if self._hgcommand != b'hg': | if self._hgcommand != b'hg': | ||||
script.append(b'alias hg="%s"\n' % self._hgcommand) | script.append(b'alias hg="%s"\n' % self._hgcommand) | ||||
if os.getenv('MSYSTEM'): | if os.getenv('MSYSTEM'): | ||||
script.append(b'alias pwd="pwd -W"\n') | script.append(b'alias pwd="pwd -W"\n') | ||||
if self._case: | if self._case: | ||||
casestr = '#'.join(self._case) | casestr = b'#'.join(self._case) | ||||
if isinstance(self._case, str): | if isinstance(self._case, str): | ||||
quoted = shellquote(casestr) | quoted = shellquote(casestr) | ||||
else: | else: | ||||
quoted = shellquote(casestr.decode('utf8')).encode('utf8') | quoted = shellquote(casestr.decode('utf8')).encode('utf8') | ||||
script.append(b'TESTCASE=%s\n' % quoted) | script.append(b'TESTCASE=%s\n' % quoted) | ||||
script.append(b'export TESTCASE\n') | script.append(b'export TESTCASE\n') | ||||
n = 0 | n = 0 | ||||
if not (os.path.basename(t).startswith(b'test-') | if not (os.path.basename(t).startswith(b'test-') | ||||
and (t.endswith(b'.py') or t.endswith(b'.t'))): | and (t.endswith(b'.py') or t.endswith(b'.t'))): | ||||
m = testcasepattern.match(t) | m = testcasepattern.match(t) | ||||
if m is not None: | if m is not None: | ||||
t, _, casestr = m.groups() | t, _, casestr = m.groups() | ||||
if casestr: | if casestr: | ||||
case = casestr.split('#') | case = casestr.split(b'#') | ||||
else: | else: | ||||
continue | continue | ||||
if t.endswith(b'.t'): | if t.endswith(b'.t'): | ||||
# .t file may contain multiple test cases | # .t file may contain multiple test cases | ||||
casedimensions = parsettestcases(t) | casedimensions = parsettestcases(t) | ||||
if casedimensions: | if casedimensions: | ||||
cases = [] | cases = [] | ||||
try: | try: | ||||
if self.options.restart: | if self.options.restart: | ||||
orig = list(testdescs) | orig = list(testdescs) | ||||
while testdescs: | while testdescs: | ||||
desc = testdescs[0] | desc = testdescs[0] | ||||
# desc['path'] is a relative path | # desc['path'] is a relative path | ||||
if 'case' in desc: | if 'case' in desc: | ||||
casestr = '#'.join(desc['case']) | casestr = b'#'.join(desc['case']) | ||||
errpath = b'%s#%s.err' % (desc['path'], casestr) | errpath = b'%s#%s.err' % (desc['path'], casestr) | ||||
else: | else: | ||||
errpath = b'%s.err' % desc['path'] | errpath = b'%s.err' % desc['path'] | ||||
errpath = os.path.join(self._outputdir, errpath) | errpath = os.path.join(self._outputdir, errpath) | ||||
if os.path.exists(errpath): | if os.path.exists(errpath): | ||||
break | break | ||||
testdescs.pop(0) | testdescs.pop(0) | ||||
if not testdescs: | if not testdescs: |