зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 19269e470c71 (bug 1594914) for causing bustages.
CLOSED TREE
This commit is contained in:
Родитель
e017fd7a57
Коммит
53a4dbf91a
1
mach
1
mach
|
@ -31,6 +31,7 @@ py2commands="
|
|||
mochitest
|
||||
mozharness
|
||||
prettier-format
|
||||
python-test
|
||||
raptor
|
||||
raptor-test
|
||||
reftest
|
||||
|
|
|
@ -11,8 +11,6 @@ import sys
|
|||
import tempfile
|
||||
from multiprocessing import cpu_count
|
||||
|
||||
import six
|
||||
|
||||
from concurrent.futures import (
|
||||
ThreadPoolExecutor,
|
||||
as_completed,
|
||||
|
@ -99,7 +97,7 @@ class MachCommands(MachCommandBase):
|
|||
action='store_true',
|
||||
help='Verbose output.')
|
||||
@CommandArgument('--python',
|
||||
default='3',
|
||||
default='2.7',
|
||||
help='Version of Python for Pipenv to use. When given a '
|
||||
'Python version, Pipenv will automatically scan your '
|
||||
'system for a Python that matches that given version.')
|
||||
|
@ -126,11 +124,7 @@ class MachCommands(MachCommandBase):
|
|||
'passed as it is to pytest'))
|
||||
def python_test(self, *args, **kwargs):
|
||||
try:
|
||||
tempdir = str(tempfile.mkdtemp(suffix='-python-test'))
|
||||
if six.PY2:
|
||||
os.environ[b'PYTHON_TEST_TMP'] = tempdir
|
||||
else:
|
||||
os.environ['PYTHON_TEST_TMP'] = tempdir
|
||||
tempdir = os.environ[b'PYTHON_TEST_TMP'] = str(tempfile.mkdtemp(suffix='-python-test'))
|
||||
return self.run_python_tests(*args, **kwargs)
|
||||
finally:
|
||||
import mozfile
|
||||
|
@ -288,7 +282,6 @@ class MachCommands(MachCommandBase):
|
|||
file_displayed_test = [] # used as boolean
|
||||
|
||||
def _line_handler(line):
|
||||
line = six.ensure_str(line)
|
||||
if not file_displayed_test:
|
||||
output = ('Ran' in line or 'collected' in line or
|
||||
line.startswith('TEST-'))
|
||||
|
@ -296,8 +289,8 @@ class MachCommands(MachCommandBase):
|
|||
file_displayed_test.append(True)
|
||||
|
||||
# Hack to make sure treeherder highlights pytest failures
|
||||
if 'FAILED' in line.rsplit(' ', 1)[-1]:
|
||||
line = line.replace('FAILED', 'TEST-UNEXPECTED-FAIL')
|
||||
if b'FAILED' in line.rsplit(b' ', 1)[-1]:
|
||||
line = line.replace(b'FAILED', b'TEST-UNEXPECTED-FAIL')
|
||||
|
||||
_log(line)
|
||||
|
||||
|
@ -305,18 +298,12 @@ class MachCommands(MachCommandBase):
|
|||
python = self.virtualenv_manager.python_path
|
||||
cmd = [python, test['path']]
|
||||
env = os.environ.copy()
|
||||
if six.PY2:
|
||||
env[b'PYTHONDONTWRITEBYTECODE'] = b'1'
|
||||
else:
|
||||
env['PYTHONDONTWRITEBYTECODE'] = '1'
|
||||
env[b'PYTHONDONTWRITEBYTECODE'] = b'1'
|
||||
|
||||
# Homebrew on OS X will change Python's sys.executable to a custom value
|
||||
# which messes with mach's virtualenv handling code. Override Homebrew's
|
||||
# changes with the correct sys.executable value.
|
||||
if six.PY2:
|
||||
env[b'PYTHONEXECUTABLE'] = python.encode('utf-8')
|
||||
else:
|
||||
env['PYTHONEXECUTABLE'] = python
|
||||
env[b'PYTHONEXECUTABLE'] = python.encode('utf-8')
|
||||
|
||||
proc = ProcessHandler(cmd, env=env, processOutputLine=_line_handler, storeOutput=False)
|
||||
proc.run()
|
||||
|
|
|
@ -20,8 +20,7 @@ def iter_modules_in_path(*paths):
|
|||
for name, module in sys.modules.items():
|
||||
if getattr(module, '__file__', None) is None:
|
||||
continue
|
||||
if module.__file__ is None:
|
||||
continue
|
||||
|
||||
path = module.__file__
|
||||
|
||||
if path.endswith('.pyc'):
|
||||
|
|
|
@ -631,12 +631,6 @@ class VirtualenvManager(object):
|
|||
# Unsetting it doesn't really matter for what pipenv does.
|
||||
env.pop('LC_CTYPE', None)
|
||||
|
||||
# Avoid click RuntimeError under python 3: http://click.pocoo.org/python3/
|
||||
env.update(ensure_subprocess_env({
|
||||
'LC_ALL': 'C.UTF-8',
|
||||
'LANG': 'C.UTF-8'
|
||||
}))
|
||||
|
||||
if python is not None:
|
||||
env.update(ensure_subprocess_env({
|
||||
'PIPENV_DEFAULT_PYTHON_VERSION': str(python),
|
||||
|
|
|
@ -62,8 +62,7 @@ def _proc_matches(args, regex):
|
|||
the given arguments"""
|
||||
output = subprocess.Popen(args=args,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
universal_newlines=True).stdout.read()
|
||||
stderr=subprocess.STDOUT).stdout.read()
|
||||
return re.findall(regex, output)
|
||||
|
||||
|
||||
|
|
|
@ -1113,7 +1113,7 @@ class ProcessReader(object):
|
|||
else:
|
||||
if output_timeout is not None:
|
||||
output_timeout = now + self.output_timeout
|
||||
callback(six.ensure_str(line).rstrip())
|
||||
callback(line.rstrip())
|
||||
if timeout is not None and now > timeout:
|
||||
timed_out = True
|
||||
break
|
||||
|
|
|
@ -4,8 +4,6 @@ import subprocess
|
|||
import sys
|
||||
import unittest
|
||||
|
||||
import six
|
||||
|
||||
import mozunit
|
||||
from mozprocess.processhandler import ProcessReader, StoreOutput
|
||||
|
||||
|
@ -40,10 +38,7 @@ class TestProcessReader(unittest.TestCase):
|
|||
self.reader.start(proc)
|
||||
self.reader.thread.join()
|
||||
|
||||
if six.PY2:
|
||||
self.assertEqual([x.decode('utf8') for x in self.out.output], ['1', '2'])
|
||||
if six.PY3:
|
||||
self.assertEqual([x for x in self.out.output], ['1', '2'])
|
||||
self.assertEqual([x.decode('utf8') for x in self.out.output], ['1', '2'])
|
||||
self.assertEqual(self.err.output, [])
|
||||
|
||||
def test_stderr_callback(self):
|
||||
|
@ -52,22 +47,15 @@ class TestProcessReader(unittest.TestCase):
|
|||
self.reader.thread.join()
|
||||
|
||||
self.assertEqual(self.out.output, [])
|
||||
if six.PY2:
|
||||
self.assertEqual([x.decode('utf8') for x in self.err.output], ['hello world'])
|
||||
elif six.PY3:
|
||||
self.assertEqual([x for x in self.err.output], ['hello world'])
|
||||
self.assertEqual([x.decode('utf8') for x in self.err.output], ['hello world'])
|
||||
|
||||
def test_stdout_and_stderr_callbacks(self):
|
||||
proc = run_python('import sys; sys.stderr.write("hello world\\n"); print(1); print(2)')
|
||||
self.reader.start(proc)
|
||||
self.reader.thread.join()
|
||||
|
||||
if six.PY2:
|
||||
self.assertEqual([x.decode('utf8') for x in self.out.output], ['1', '2'])
|
||||
self.assertEqual([x.decode('utf8') for x in self.err.output], ['hello world'])
|
||||
elif six.PY3:
|
||||
self.assertEqual([x for x in self.out.output], ['1', '2'])
|
||||
self.assertEqual([x for x in self.err.output], ['hello world'])
|
||||
self.assertEqual([x.decode('utf8') for x in self.out.output], ['1', '2'])
|
||||
self.assertEqual([x.decode('utf8') for x in self.err.output], ['hello world'])
|
||||
|
||||
def test_finished_callback(self):
|
||||
self.assertFalse(self.finished)
|
||||
|
@ -98,31 +86,22 @@ class TestProcessReader(unittest.TestCase):
|
|||
proc = run_python('import sys; sys.stdout.write("1")')
|
||||
self.reader.start(proc)
|
||||
self.reader.thread.join()
|
||||
if six.PY2:
|
||||
self.assertEqual([x.decode('utf8') for x in self.out.output], ['1'])
|
||||
elif six.PY3:
|
||||
self.assertEqual([x for x in self.out.output], ['1'])
|
||||
self.assertEqual([x.decode('utf8') for x in self.out.output], ['1'])
|
||||
|
||||
def test_read_with_strange_eol(self):
|
||||
proc = run_python('import sys; sys.stdout.write("1\\r\\r\\r\\n")')
|
||||
self.reader.start(proc)
|
||||
self.reader.thread.join()
|
||||
if six.PY2:
|
||||
self.assertEqual([x.decode('utf8') for x in self.out.output], ['1'])
|
||||
elif six.PY3:
|
||||
self.assertEqual([x for x in self.out.output], ['1'])
|
||||
self.assertEqual([x.decode('utf8') for x in self.out.output], ['1'])
|
||||
|
||||
def test_mixed_stdout_stderr(self):
|
||||
proc = run_python('import sys; sys.stderr.write("hello world\\n"); print(1); print(2)',
|
||||
stderr=subprocess.STDOUT)
|
||||
self.reader.start(proc)
|
||||
self.reader.thread.join()
|
||||
if six.PY2:
|
||||
self.assertEqual(sorted([x.decode('utf8') for x in self.out.output]),
|
||||
sorted(['1', '2', 'hello world']))
|
||||
elif six.PY3:
|
||||
self.assertEqual(sorted([x for x in self.out.output]),
|
||||
sorted(['1', '2', 'hello world']))
|
||||
|
||||
self.assertEqual(sorted([x.decode('utf8') for x in self.out.output]),
|
||||
sorted(['1', '2', 'hello world']))
|
||||
self.assertEqual(self.err.output, [])
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче