Bug 1472177 - Run mozversioncontrol tests under python 3 r=gps

This also enables the py2 linter which will help maintain compatibility
with both 2 and 3.

Differential Revision: https://phabricator.services.mozilla.com/D1884

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrew Halberstadt 2018-07-24 21:21:46 +00:00
Родитель 5574f1d788
Коммит 21dc8454f4
6 изменённых файлов: 18 добавлений и 23 удалений

Просмотреть файл

@ -9,8 +9,8 @@ import errno
import os
import re
import subprocess
import which
from distutils.spawn import find_executable
from distutils.version import LooseVersion
@ -48,22 +48,12 @@ def get_tool_path(tool):
if os.path.isabs(tool) and os.path.exists(tool):
return tool
# We use subprocess in places, which expects a Win32 executable or
# batch script. On some versions of MozillaBuild, we have "hg.exe",
# "hg.bat," and "hg" (a Python script). "which" will happily return the
# Python script, which will cause subprocess to choke. Explicitly favor
# the Windows version over the plain script.
try:
return which.which(tool + '.exe')
except which.WhichError:
try:
return which.which(tool)
except which.WhichError:
pass
raise MissingVCSTool('Unable to obtain %s path. Try running '
'|mach bootstrap| to ensure your environment is up to '
'date.' % tool)
path = find_executable(tool)
if not path:
raise MissingVCSTool('Unable to obtain %s path. Try running '
'|mach bootstrap| to ensure your environment is up to '
'date.' % tool)
return path
class Repository(object):
@ -98,7 +88,8 @@ class Repository(object):
try:
return subprocess.check_output(cmd,
cwd=self.path,
env=self._env)
env=self._env,
universal_newlines=True)
except subprocess.CalledProcessError as e:
if e.returncode in return_codes:
return ''
@ -263,7 +254,10 @@ class HgRepository(Repository):
def _run(self, *args, **runargs):
if not self._client.server:
return super(HgRepository, self)._run(*args, **runargs)
return self._client.rawcommand(args)
# hglib requires bytes on python 3
args = [a.encode('utf-8') if not isinstance(a, bytes) else a for a in args]
return self._client.rawcommand(args).decode('utf-8')
def sparse_checkout_present(self):
# We assume a sparse checkout is enabled if the .hg/sparse file

Просмотреть файл

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this,
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import unicode_literals
from __future__ import absolute_import, unicode_literals
import os
import subprocess

Просмотреть файл

@ -20,7 +20,10 @@ setup(
'Development Status :: 3 - Alpha',
'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: Implementation :: CPython',
],
keywords='mozilla',

Просмотреть файл

@ -1,6 +1,5 @@
[DEFAULT]
subsuite=mozversioncontrol
skip-if = python == 3
[test_context_manager.py]
[test_push_to_try.py]

Просмотреть файл

@ -138,7 +138,7 @@ mozterm:
mozversioncontrol:
description: python/mozversioncontrol unit tests
python-version: [2]
python-version: [2, 3]
treeherder:
symbol: vcs
run:

Просмотреть файл

@ -29,7 +29,6 @@ py2:
- python/devtools
- python/mach
- python/mozbuild
- python/mozversioncontrol
- security
- servo
- taskcluster/docker/funsize-update-generator