mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 07:15:46 +00:00
Backed out 5 changesets (bug 1607345, bug 1607284, bug 1607512
, bug 1563797, bug 1607503) for flake8 failure at python/mozbuild/mozbuild/configure/__init__.py on a CLOSED TREE
Backed out changeset 8dab339bab78 (bug 1607512
)
Backed out changeset 1c5880c1c459 (bug 1607503)
Backed out changeset 42a69c5056b0 (bug 1607345)
Backed out changeset 431cb34ec6b0 (bug 1607284)
Backed out changeset 9837631a9c71 (bug 1563797)
This commit is contained in:
parent
798b9b9ec1
commit
c9e1368a0f
@ -57,7 +57,7 @@ def checking(what, callback=None):
|
||||
try:
|
||||
ret = func(*args, **kwargs)
|
||||
except FatalCheckError as e:
|
||||
error = str(e)
|
||||
error = e.message
|
||||
display_ret = callback(ret) if callback else ret
|
||||
if display_ret is True:
|
||||
log.info('yes')
|
||||
|
@ -23,21 +23,22 @@ def configure_error(message):
|
||||
# A wrapper to obtain a process' output and return code.
|
||||
# Returns a tuple (retcode, stdout, stderr).
|
||||
@imports('os')
|
||||
@imports('six')
|
||||
@imports('subprocess')
|
||||
@imports(_from='mozbuild.shellutil', _import='quote')
|
||||
@imports(_from='mozbuild.util', _import='system_encoding')
|
||||
def get_cmd_output(*args, **kwargs):
|
||||
log.debug('Executing: `%s`', quote(*args))
|
||||
proc = subprocess.Popen(
|
||||
args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
# On Python 2 on Windows, close_fds prevents the process from inheriting
|
||||
# stdout/stderr. Elsewhere, it simply prevents it from inheriting extra
|
||||
# file descriptors, which is what we want.
|
||||
close_fds=os.name != 'nt', universal_newlines=True, **kwargs)
|
||||
proc = subprocess.Popen(args, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
# On Python 2 on Windows, close_fds prevents the
|
||||
# process from inheriting stdout/stderr.
|
||||
# Elsewhere, it simply prevents it from inheriting
|
||||
# extra file descriptors, which is what we want.
|
||||
close_fds=os.name != 'nt',
|
||||
**kwargs)
|
||||
stdout, stderr = proc.communicate()
|
||||
stdout = six.ensure_text(stdout, encoding=system_encoding, errors='replace')
|
||||
stderr = six.ensure_text(stderr, encoding=system_encoding, errors='replace')
|
||||
stdout = stdout.decode(system_encoding, 'replace')
|
||||
stderr = stderr.decode(system_encoding, 'replace')
|
||||
return proc.wait(), stdout, stderr
|
||||
|
||||
|
||||
@ -161,10 +162,12 @@ normalize_path = normalize_path()
|
||||
# exists.
|
||||
# The `paths` parameter may be passed to search the given paths instead of
|
||||
# $PATH.
|
||||
@imports(_from='which', _import='which')
|
||||
@imports(_from='which', _import='WhichError')
|
||||
@imports('itertools')
|
||||
@imports('sys')
|
||||
@imports(_from='os', _import='pathsep')
|
||||
@imports(_from='os', _import='environ')
|
||||
@imports(_from='mozfile', _import='which')
|
||||
def find_program(file, paths=None):
|
||||
# The following snippet comes from `which` itself, with a slight
|
||||
# modification to use lowercase extensions, because it's confusing rustup
|
||||
@ -181,18 +184,21 @@ def find_program(file, paths=None):
|
||||
else:
|
||||
exts = None
|
||||
|
||||
if is_absolute_or_relative(file):
|
||||
path = which(os.path.basename(file), path=os.path.dirname(file), exts=exts)
|
||||
return normalize_path(path) if path else None
|
||||
|
||||
if paths:
|
||||
if not isinstance(paths, (list, tuple)):
|
||||
die("Paths provided to find_program must be a list of strings, "
|
||||
"not %r", paths)
|
||||
paths = pathsep.join(paths)
|
||||
|
||||
path = which(file, path=paths, exts=exts)
|
||||
return normalize_path(path) if path else None
|
||||
try:
|
||||
if is_absolute_or_relative(file):
|
||||
return normalize_path(which(os.path.basename(file),
|
||||
[os.path.dirname(file)], exts=exts))
|
||||
if paths:
|
||||
if not isinstance(paths, (list, tuple)):
|
||||
die("Paths provided to find_program must be a list of strings, "
|
||||
"not %r", paths)
|
||||
paths = list(itertools.chain(
|
||||
*(p.split(pathsep) for p in paths if p)))
|
||||
else:
|
||||
paths = environ['PATH'].split(pathsep)
|
||||
return normalize_path(which(file, path=paths, exts=exts))
|
||||
except WhichError:
|
||||
return None
|
||||
|
||||
|
||||
@imports('os')
|
||||
|
@ -170,7 +170,7 @@ class MockedOpen(object):
|
||||
for name, content in files.items():
|
||||
self.files[normcase(os.path.abspath(name))] = content
|
||||
|
||||
def __call__(self, name, mode='r', buffering=None, encoding=None):
|
||||
def __call__(self, name, mode='r', buffering=None):
|
||||
# buffering is ignored.
|
||||
absname = normcase(os.path.abspath(name))
|
||||
if 'w' in mode:
|
||||
|
@ -280,7 +280,7 @@ class MozbuildObject(ProcessExecutionMixin):
|
||||
# the environment variable, which has an impact on autodetection (when
|
||||
# path is MozconfigLoader.AUTODETECT), and memoization wouldn't account
|
||||
# for it without the explicit (unused) argument.
|
||||
out = six.StringIO()
|
||||
out = six.BytesIO()
|
||||
env = os.environ
|
||||
if path and path != MozconfigLoader.AUTODETECT:
|
||||
env = dict(env)
|
||||
|
@ -373,10 +373,13 @@ class ConfigureSandbox(dict):
|
||||
|
||||
def wrapped_log_method(logger, key):
|
||||
method = getattr(logger, key)
|
||||
if not encoding:
|
||||
return method
|
||||
|
||||
def wrapped(*args, **kwargs):
|
||||
out_args = [
|
||||
six.ensure_text(arg, encoding=encoding or 'utf-8')
|
||||
if isinstance(arg, six.binary_type) else arg for arg in args
|
||||
arg.decode(encoding) if isinstance(arg, six.binary_type) else arg
|
||||
for arg in args
|
||||
]
|
||||
return method(*out_args, **kwargs)
|
||||
return wrapped
|
||||
@ -913,9 +916,7 @@ class ConfigureSandbox(dict):
|
||||
# fails with "IOError: file() constructor not accessible in
|
||||
# restricted mode". We also make open() look more like python 3's,
|
||||
# decoding to unicode strings unless the mode says otherwise.
|
||||
if what == '__builtin__.open' or what == 'builtins.open':
|
||||
if six.PY3:
|
||||
return open
|
||||
if what == '__builtin__.open':
|
||||
def wrapped_open(name, mode=None, buffering=None):
|
||||
args = (name,)
|
||||
kwargs = {}
|
||||
@ -948,8 +949,6 @@ class ConfigureSandbox(dict):
|
||||
if _from == '__builtin__' or _from.startswith('__builtin__.'):
|
||||
_from = _from.replace('__builtin__', 'six.moves.builtins')
|
||||
import_line += 'from %s ' % _from
|
||||
if what == '__builtin__':
|
||||
what = 'six.moves.builtins'
|
||||
import_line += 'import %s as imported' % what
|
||||
glob = {}
|
||||
exec_(import_line, {}, glob)
|
||||
|
@ -304,7 +304,7 @@ class Option(object):
|
||||
', '.join("'%s'" % c for c in choices))
|
||||
elif has_choices:
|
||||
maxargs = self.maxargs
|
||||
if len(choices) < maxargs and maxargs != sys.maxsize:
|
||||
if len(choices) < maxargs and maxargs != sys.maxint:
|
||||
raise InvalidOptionError('Not enough `choices` for `nargs`')
|
||||
self.choices = choices
|
||||
self.help = help
|
||||
@ -372,7 +372,7 @@ class Option(object):
|
||||
def maxargs(self):
|
||||
if isinstance(self.nargs, int):
|
||||
return self.nargs
|
||||
return 1 if self.nargs == '?' else sys.maxsize
|
||||
return 1 if self.nargs == '?' else sys.maxint
|
||||
|
||||
def _validate_nargs(self, num):
|
||||
minargs, maxargs = self.minargs, self.maxargs
|
||||
|
@ -83,8 +83,6 @@ class ConfigureOutputHandler(logging.Handler):
|
||||
# Python has this feature where it sets the encoding of pipes to
|
||||
# ascii, which blatantly fails when trying to print out non-ascii.
|
||||
def fix_encoding(fh):
|
||||
if six.PY3:
|
||||
return fh
|
||||
try:
|
||||
isatty = fh.isatty()
|
||||
except AttributeError:
|
||||
@ -130,7 +128,7 @@ class ConfigureOutputHandler(logging.Handler):
|
||||
try:
|
||||
if record.levelno == logging.INFO:
|
||||
stream = self._stdout
|
||||
msg = six.ensure_text(record.getMessage())
|
||||
msg = record.getMessage()
|
||||
if (self._stdout_waiting == self.INTERRUPTED and
|
||||
self._same_output):
|
||||
msg = ' ... %s' % msg
|
||||
@ -209,7 +207,8 @@ class LineIO(object):
|
||||
self._errors = errors
|
||||
|
||||
def write(self, buf):
|
||||
buf = six.ensure_text(buf, encoding=self._encoding or 'utf-8')
|
||||
if self._encoding and isinstance(buf, str):
|
||||
buf = buf.decode(self._encoding, self._errors)
|
||||
lines = buf.splitlines()
|
||||
if not lines:
|
||||
return
|
||||
|
@ -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 absolute_import, print_function, unicode_literals
|
||||
from __future__ import absolute_import, print_function
|
||||
|
||||
import re
|
||||
|
||||
|
@ -7,17 +7,17 @@ from __future__ import absolute_import, print_function, unicode_literals
|
||||
import copy
|
||||
import errno
|
||||
import os
|
||||
import six
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from six import StringIO
|
||||
|
||||
from mozbuild.configure import ConfigureSandbox
|
||||
from mozbuild.util import ReadOnlyNamespace
|
||||
from mozpack import path as mozpath
|
||||
from six import string_types
|
||||
|
||||
from StringIO import StringIO
|
||||
from which import WhichError
|
||||
|
||||
from buildconfig import (
|
||||
topobjdir,
|
||||
@ -79,10 +79,10 @@ class ConfigureTestSandbox(ConfigureSandbox):
|
||||
self._search_path = environ.get('PATH', '').split(os.pathsep)
|
||||
|
||||
self._subprocess_paths = {
|
||||
mozpath.abspath(k): v for k, v in six.iteritems(paths) if v
|
||||
mozpath.abspath(k): v for k, v in paths.iteritems() if v
|
||||
}
|
||||
|
||||
paths = list(paths)
|
||||
paths = paths.keys()
|
||||
|
||||
environ = copy.copy(environ)
|
||||
if 'CONFIG_SHELL' not in environ:
|
||||
@ -110,12 +110,13 @@ class ConfigureTestSandbox(ConfigureSandbox):
|
||||
if what in self.modules:
|
||||
return self.modules[what]
|
||||
|
||||
if what == 'mozfile.which':
|
||||
if what == 'which.which':
|
||||
return self.which
|
||||
|
||||
if what == 'mozfile':
|
||||
if what == 'which':
|
||||
return ReadOnlyNamespace(
|
||||
which=self.which,
|
||||
WhichError=WhichError,
|
||||
)
|
||||
|
||||
if what == 'subprocess.Popen':
|
||||
@ -185,20 +186,18 @@ class ConfigureTestSandbox(ConfigureSandbox):
|
||||
path_out.value = fake_short_path(path_in)
|
||||
return length
|
||||
|
||||
def which(self, command, mode=None, path=None, exts=None):
|
||||
if isinstance(path, string_types):
|
||||
path = path.split(os.pathsep)
|
||||
|
||||
def which(self, command, path=None, exts=None):
|
||||
for parent in (path or self._search_path):
|
||||
c = mozpath.abspath(mozpath.join(parent, command))
|
||||
for candidate in (c, ensure_exe_extension(c)):
|
||||
if self.imported_os.path.exists(candidate):
|
||||
return candidate
|
||||
return None
|
||||
raise WhichError()
|
||||
|
||||
def Popen(self, args, stdin=None, stdout=None, stderr=None, **kargs):
|
||||
program = self.which(args[0])
|
||||
if not program:
|
||||
try:
|
||||
program = self.which(args[0])
|
||||
except WhichError:
|
||||
raise OSError(errno.ENOENT, 'File not found')
|
||||
|
||||
func = self._subprocess_paths.get(program)
|
||||
|
@ -13,9 +13,9 @@ def dies_when_logging(_):
|
||||
test_file = 'test.txt'
|
||||
quote_char = "'"
|
||||
if getpreferredencoding().lower() == 'utf-8':
|
||||
quote_char = '\u00B4'
|
||||
quote_char = '\u00B4'.encode('utf-8')
|
||||
try:
|
||||
with open(test_file, 'w+t') as fh:
|
||||
with open(test_file, 'w+b') as fh:
|
||||
fh.write(quote_char)
|
||||
out = check_cmd_output('cat', 'test.txt')
|
||||
log.info(out)
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
from six import StringIO
|
||||
from StringIO import StringIO
|
||||
import os
|
||||
import sys
|
||||
import textwrap
|
||||
@ -33,45 +33,71 @@ from common import (
|
||||
|
||||
class TestChecksConfigure(unittest.TestCase):
|
||||
def test_checking(self):
|
||||
def make_test(to_exec):
|
||||
def test(val, msg):
|
||||
out = StringIO()
|
||||
sandbox = ConfigureSandbox({}, stdout=out, stderr=out)
|
||||
base_dir = os.path.join(topsrcdir, 'build', 'moz.configure')
|
||||
sandbox.include_file(os.path.join(base_dir, 'checks.configure'))
|
||||
exec_(to_exec, sandbox)
|
||||
sandbox['foo'](val)
|
||||
self.assertEqual(out.getvalue(), msg)
|
||||
out = StringIO()
|
||||
sandbox = ConfigureSandbox({}, stdout=out, stderr=out)
|
||||
base_dir = os.path.join(topsrcdir, 'build', 'moz.configure')
|
||||
sandbox.include_file(os.path.join(base_dir, 'checks.configure'))
|
||||
|
||||
return test
|
||||
|
||||
test = make_test(textwrap.dedent('''
|
||||
exec_(textwrap.dedent('''
|
||||
@checking('for a thing')
|
||||
def foo(value):
|
||||
return value
|
||||
'''))
|
||||
test(True, 'checking for a thing... yes\n')
|
||||
test(False, 'checking for a thing... no\n')
|
||||
test(42, 'checking for a thing... 42\n')
|
||||
test('foo', 'checking for a thing... foo\n')
|
||||
'''), sandbox)
|
||||
|
||||
foo = sandbox['foo']
|
||||
|
||||
foo(True)
|
||||
self.assertEqual(out.getvalue(), 'checking for a thing... yes\n')
|
||||
|
||||
out.truncate(0)
|
||||
foo(False)
|
||||
self.assertEqual(out.getvalue(), 'checking for a thing... no\n')
|
||||
|
||||
out.truncate(0)
|
||||
foo(42)
|
||||
self.assertEqual(out.getvalue(), 'checking for a thing... 42\n')
|
||||
|
||||
out.truncate(0)
|
||||
foo('foo')
|
||||
self.assertEqual(out.getvalue(), 'checking for a thing... foo\n')
|
||||
|
||||
out.truncate(0)
|
||||
data = ['foo', 'bar']
|
||||
test(data, 'checking for a thing... %r\n' % data)
|
||||
foo(data)
|
||||
self.assertEqual(out.getvalue(), 'checking for a thing... %r\n' % data)
|
||||
|
||||
# When the function given to checking does nothing interesting, the
|
||||
# behavior is not altered
|
||||
test = make_test(textwrap.dedent('''
|
||||
exec_(textwrap.dedent('''
|
||||
@checking('for a thing', lambda x: x)
|
||||
def foo(value):
|
||||
return value
|
||||
'''))
|
||||
test(True, 'checking for a thing... yes\n')
|
||||
test(False, 'checking for a thing... no\n')
|
||||
test(42, 'checking for a thing... 42\n')
|
||||
test('foo', 'checking for a thing... foo\n')
|
||||
data = ['foo', 'bar']
|
||||
test(data, 'checking for a thing... %r\n' % data)
|
||||
'''), sandbox)
|
||||
|
||||
test = make_test(textwrap.dedent('''
|
||||
foo = sandbox['foo']
|
||||
|
||||
out.truncate(0)
|
||||
foo(True)
|
||||
self.assertEqual(out.getvalue(), 'checking for a thing... yes\n')
|
||||
|
||||
out.truncate(0)
|
||||
foo(False)
|
||||
self.assertEqual(out.getvalue(), 'checking for a thing... no\n')
|
||||
|
||||
out.truncate(0)
|
||||
foo(42)
|
||||
self.assertEqual(out.getvalue(), 'checking for a thing... 42\n')
|
||||
|
||||
out.truncate(0)
|
||||
foo('foo')
|
||||
self.assertEqual(out.getvalue(), 'checking for a thing... foo\n')
|
||||
|
||||
out.truncate(0)
|
||||
data = ['foo', 'bar']
|
||||
foo(data)
|
||||
self.assertEqual(out.getvalue(), 'checking for a thing... %r\n' % data)
|
||||
|
||||
exec_(textwrap.dedent('''
|
||||
def munge(x):
|
||||
if not x:
|
||||
return 'not found'
|
||||
@ -82,13 +108,29 @@ class TestChecksConfigure(unittest.TestCase):
|
||||
@checking('for a thing', munge)
|
||||
def foo(value):
|
||||
return value
|
||||
'''))
|
||||
test(True, 'checking for a thing... yes\n')
|
||||
test(False, 'checking for a thing... not found\n')
|
||||
test(42, 'checking for a thing... 42\n')
|
||||
test('foo', 'checking for a thing... foo\n')
|
||||
data = ['foo', 'bar']
|
||||
test(data, 'checking for a thing... foo bar\n')
|
||||
'''), sandbox)
|
||||
|
||||
foo = sandbox['foo']
|
||||
|
||||
out.truncate(0)
|
||||
foo(True)
|
||||
self.assertEqual(out.getvalue(), 'checking for a thing... yes\n')
|
||||
|
||||
out.truncate(0)
|
||||
foo(False)
|
||||
self.assertEqual(out.getvalue(), 'checking for a thing... not found\n')
|
||||
|
||||
out.truncate(0)
|
||||
foo(42)
|
||||
self.assertEqual(out.getvalue(), 'checking for a thing... 42\n')
|
||||
|
||||
out.truncate(0)
|
||||
foo('foo')
|
||||
self.assertEqual(out.getvalue(), 'checking for a thing... foo\n')
|
||||
|
||||
out.truncate(0)
|
||||
foo(['foo', 'bar'])
|
||||
self.assertEqual(out.getvalue(), 'checking for a thing... foo bar\n')
|
||||
|
||||
KNOWN_A = ensure_exe_extension(mozpath.abspath('/usr/bin/known-a'))
|
||||
KNOWN_B = ensure_exe_extension(mozpath.abspath('/usr/local/bin/known-b'))
|
||||
@ -364,7 +406,7 @@ class TestChecksConfigure(unittest.TestCase):
|
||||
with self.assertRaises(ConfigureError) as e:
|
||||
self.get_result('check_prog("FOO", "foo")')
|
||||
|
||||
self.assertEqual(str(e.exception),
|
||||
self.assertEqual(e.exception.message,
|
||||
'progs must resolve to a list or tuple!')
|
||||
|
||||
with self.assertRaises(ConfigureError) as e:
|
||||
@ -373,7 +415,7 @@ class TestChecksConfigure(unittest.TestCase):
|
||||
'check_prog("FOO", ("known-a",), input=foo)'
|
||||
)
|
||||
|
||||
self.assertEqual(str(e.exception),
|
||||
self.assertEqual(e.exception.message,
|
||||
'input must resolve to a tuple or a list with a '
|
||||
'single element, or a string')
|
||||
|
||||
@ -383,7 +425,7 @@ class TestChecksConfigure(unittest.TestCase):
|
||||
'check_prog("FOO", ("known-a",), input=foo)'
|
||||
)
|
||||
|
||||
self.assertEqual(str(e.exception),
|
||||
self.assertEqual(e.exception.message,
|
||||
'input must resolve to a tuple or a list with a '
|
||||
'single element, or a string')
|
||||
|
||||
|
@ -4,9 +4,8 @@
|
||||
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
from six import StringIO
|
||||
from StringIO import StringIO
|
||||
import os
|
||||
import six
|
||||
import sys
|
||||
import textwrap
|
||||
import unittest
|
||||
@ -43,7 +42,7 @@ class TestConfigure(unittest.TestCase):
|
||||
sandbox.run(mozpath.join(test_data_path, configure))
|
||||
|
||||
if '--help' in options:
|
||||
return six.ensure_text(out.getvalue()), config
|
||||
return out.getvalue().decode('utf-8'), config
|
||||
self.assertEquals('', out.getvalue())
|
||||
return config
|
||||
|
||||
@ -295,7 +294,8 @@ class TestConfigure(unittest.TestCase):
|
||||
sandbox
|
||||
)
|
||||
|
||||
self.assertIs(sandbox['foo'](), six.moves.builtins)
|
||||
import __builtin__
|
||||
self.assertIs(sandbox['foo'](), __builtin__)
|
||||
|
||||
exec_(textwrap.dedent('''
|
||||
@template
|
||||
@ -342,7 +342,7 @@ class TestConfigure(unittest.TestCase):
|
||||
self.assertIs(sandbox['foo'](), sandbox)
|
||||
|
||||
# Nothing leaked from the function being executed
|
||||
self.assertEquals(list(sandbox), ['__builtins__', 'foo'])
|
||||
self.assertEquals(sandbox.keys(), ['__builtins__', 'foo'])
|
||||
self.assertEquals(sandbox['__builtins__'], ConfigureSandbox.BUILTINS)
|
||||
|
||||
exec_(textwrap.dedent('''
|
||||
@ -360,7 +360,8 @@ class TestConfigure(unittest.TestCase):
|
||||
with self.assertRaises(NameError) as e:
|
||||
sandbox._depends[sandbox['bar']].result()
|
||||
|
||||
self.assertIn("name 'sys' is not defined", str(e.exception))
|
||||
self.assertEquals(e.exception.message,
|
||||
"global name 'sys' is not defined")
|
||||
|
||||
def test_apply_imports(self):
|
||||
imports = []
|
||||
@ -536,7 +537,7 @@ class TestConfigure(unittest.TestCase):
|
||||
get_config(['--enable-foo', '--disable-bar'])
|
||||
|
||||
self.assertEquals(
|
||||
str(e.exception),
|
||||
e.exception.message,
|
||||
"'--enable-bar' implied by '--enable-foo' conflicts with "
|
||||
"'--disable-bar' from the command-line")
|
||||
|
||||
@ -559,7 +560,7 @@ class TestConfigure(unittest.TestCase):
|
||||
get_config(['--enable-foo', '--enable-bar'])
|
||||
|
||||
self.assertEquals(
|
||||
str(e.exception),
|
||||
e.exception.message,
|
||||
"'--disable-bar' implied by '--enable-foo' conflicts with "
|
||||
"'--enable-bar' from the command-line")
|
||||
|
||||
@ -571,7 +572,7 @@ class TestConfigure(unittest.TestCase):
|
||||
get_config(['--disable-hoge', '--enable-bar'])
|
||||
|
||||
self.assertEquals(
|
||||
str(e.exception),
|
||||
e.exception.message,
|
||||
"'--disable-bar' implied by '--disable-hoge' conflicts with "
|
||||
"'--enable-bar' from the command-line")
|
||||
|
||||
@ -598,7 +599,7 @@ class TestConfigure(unittest.TestCase):
|
||||
get_config(['--enable-foo=a,b', '--disable-bar'])
|
||||
|
||||
self.assertEquals(
|
||||
str(e.exception),
|
||||
e.exception.message,
|
||||
"'--enable-bar=a,b' implied by '--enable-foo' conflicts with "
|
||||
"'--disable-bar' from the command-line")
|
||||
|
||||
@ -617,7 +618,7 @@ class TestConfigure(unittest.TestCase):
|
||||
get_config(['--enable-foo', '--disable-bar'])
|
||||
|
||||
self.assertEquals(
|
||||
str(e.exception),
|
||||
e.exception.message,
|
||||
"'--enable-bar' implied by '--enable-foo' conflicts with "
|
||||
"'--disable-bar' from the command-line")
|
||||
|
||||
@ -625,7 +626,7 @@ class TestConfigure(unittest.TestCase):
|
||||
self.get_config([], configure='imply_option/infer_ko.configure')
|
||||
|
||||
self.assertEquals(
|
||||
str(e.exception),
|
||||
e.exception.message,
|
||||
"Cannot infer what implies '--enable-bar'. Please add a `reason` "
|
||||
"to the `imply_option` call.")
|
||||
|
||||
@ -667,7 +668,7 @@ class TestConfigure(unittest.TestCase):
|
||||
'''):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"`--with-foo`, emitted from `%s` line 2, is unknown."
|
||||
% mozpath.join(test_data_path, 'moz.configure'))
|
||||
|
||||
@ -682,7 +683,7 @@ class TestConfigure(unittest.TestCase):
|
||||
'''):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"Unexpected type: 'int'")
|
||||
|
||||
def test_imply_option_when(self):
|
||||
@ -738,7 +739,7 @@ class TestConfigure(unittest.TestCase):
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
config = self.get_config(['--without-foo', '--with-qux'])
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"'--with-foo' implied by '--with-qux' conflicts "
|
||||
"with '--without-foo' from the command-line")
|
||||
|
||||
@ -777,14 +778,14 @@ class TestConfigure(unittest.TestCase):
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
config = self.get_config(['--with-qux'])
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"'--with-foo' implied by '--with-qux' conflicts "
|
||||
"with '--without-foo' from the default")
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
config = self.get_config(['--without-foo', '--with-qux'])
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"'--with-foo' implied by '--with-qux' conflicts "
|
||||
"with '--without-foo' from the command-line")
|
||||
|
||||
@ -827,14 +828,14 @@ class TestConfigure(unittest.TestCase):
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
config = self.get_config(['--with-qux'])
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"'--with-foo' implied by 'imply_option at %s:10' conflicts "
|
||||
"with '--without-foo' from the default" % config_path)
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
config = self.get_config(['--without-foo', '--with-qux'])
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"'--with-foo' implied by 'imply_option at %s:10' conflicts "
|
||||
"with '--without-foo' from the command-line" % config_path)
|
||||
|
||||
@ -869,17 +870,17 @@ class TestConfigure(unittest.TestCase):
|
||||
with self.assertRaises(ConfigureError) as e:
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(str(e.exception), message)
|
||||
self.assertEquals(e.exception.message, message)
|
||||
|
||||
with self.assertRaises(ConfigureError) as e:
|
||||
self.get_config(['--with-qux'])
|
||||
|
||||
self.assertEquals(str(e.exception), message)
|
||||
self.assertEquals(e.exception.message, message)
|
||||
|
||||
with self.assertRaises(ConfigureError) as e:
|
||||
self.get_config(['--without-foo', '--with-qux'])
|
||||
|
||||
self.assertEquals(str(e.exception), message)
|
||||
self.assertEquals(e.exception.message, message)
|
||||
|
||||
def test_option_failures(self):
|
||||
with self.assertRaises(ConfigureError) as e:
|
||||
@ -887,7 +888,7 @@ class TestConfigure(unittest.TestCase):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(
|
||||
str(e.exception),
|
||||
e.exception.message,
|
||||
'Option `--with-foo` is not handled ; reference it with a @depends'
|
||||
)
|
||||
|
||||
@ -899,7 +900,7 @@ class TestConfigure(unittest.TestCase):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(
|
||||
str(e.exception),
|
||||
e.exception.message,
|
||||
'Option `--with-foo` already defined'
|
||||
)
|
||||
|
||||
@ -911,7 +912,7 @@ class TestConfigure(unittest.TestCase):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(
|
||||
str(e.exception),
|
||||
e.exception.message,
|
||||
'Option `MOZ_FOO` already defined'
|
||||
)
|
||||
|
||||
@ -923,7 +924,7 @@ class TestConfigure(unittest.TestCase):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(
|
||||
str(e.exception),
|
||||
e.exception.message,
|
||||
'Option `MOZ_FOO` already defined'
|
||||
)
|
||||
|
||||
@ -935,7 +936,7 @@ class TestConfigure(unittest.TestCase):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(
|
||||
str(e.exception),
|
||||
e.exception.message,
|
||||
'Option `MOZ_FOO` already defined'
|
||||
)
|
||||
|
||||
@ -947,7 +948,7 @@ class TestConfigure(unittest.TestCase):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(
|
||||
str(e.exception),
|
||||
e.exception.message,
|
||||
'Option `--with-foo` already defined'
|
||||
)
|
||||
|
||||
@ -982,7 +983,7 @@ class TestConfigure(unittest.TestCase):
|
||||
self.get_config(['--with-bar'])
|
||||
|
||||
self.assertEquals(
|
||||
str(e.exception),
|
||||
e.exception.message,
|
||||
'--with-bar is not available in this configuration'
|
||||
)
|
||||
|
||||
@ -990,7 +991,7 @@ class TestConfigure(unittest.TestCase):
|
||||
self.get_config(['--with-qux'])
|
||||
|
||||
self.assertEquals(
|
||||
str(e.exception),
|
||||
e.exception.message,
|
||||
'--with-qux is not available in this configuration'
|
||||
)
|
||||
|
||||
@ -998,7 +999,7 @@ class TestConfigure(unittest.TestCase):
|
||||
self.get_config(['QUX=1'])
|
||||
|
||||
self.assertEquals(
|
||||
str(e.exception),
|
||||
e.exception.message,
|
||||
'QUX is not available in this configuration'
|
||||
)
|
||||
|
||||
@ -1045,7 +1046,7 @@ class TestConfigure(unittest.TestCase):
|
||||
with self.assertRaises(ConfigureError) as e:
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'@depends function needs the same `when` as '
|
||||
'options it depends on')
|
||||
|
||||
@ -1062,7 +1063,7 @@ class TestConfigure(unittest.TestCase):
|
||||
with self.assertRaises(ConfigureError) as e:
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'@depends function needs the same `when` as '
|
||||
'options it depends on')
|
||||
|
||||
@ -1116,7 +1117,7 @@ class TestConfigure(unittest.TestCase):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(
|
||||
str(e.exception),
|
||||
e.exception.message,
|
||||
'Cannot include `%s` because it is not in a subdirectory of `%s`'
|
||||
% (mozpath.normpath(mozpath.join(test_data_path, '..',
|
||||
'foo.configure')),
|
||||
@ -1131,7 +1132,7 @@ class TestConfigure(unittest.TestCase):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(
|
||||
str(e.exception),
|
||||
e.exception.message,
|
||||
'Cannot include `%s` because it was included already.'
|
||||
% mozpath.normpath(mozpath.join(test_data_path,
|
||||
'extra.configure'))
|
||||
@ -1143,7 +1144,7 @@ class TestConfigure(unittest.TestCase):
|
||||
'''):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(str(e.exception), "Unexpected type: 'int'")
|
||||
self.assertEquals(e.exception.message, "Unexpected type: 'int'")
|
||||
|
||||
def test_include_when(self):
|
||||
with MockedOpen({
|
||||
@ -1200,7 +1201,7 @@ class TestConfigure(unittest.TestCase):
|
||||
self.get_config(['--with-qux'])
|
||||
|
||||
self.assertEquals(
|
||||
str(e.exception),
|
||||
e.exception.message,
|
||||
'--with-qux is not available in this configuration'
|
||||
)
|
||||
|
||||
@ -1217,7 +1218,7 @@ class TestConfigure(unittest.TestCase):
|
||||
'''):
|
||||
self.get_config()
|
||||
|
||||
self.assertIn('Cannot reassign builtins', str(e.exception))
|
||||
self.assertEquals(e.exception.message, 'Cannot reassign builtins')
|
||||
|
||||
with self.assertRaises(KeyError) as e:
|
||||
with self.moz_configure('''
|
||||
@ -1225,9 +1226,9 @@ class TestConfigure(unittest.TestCase):
|
||||
'''):
|
||||
self.get_config()
|
||||
|
||||
self.assertIn(
|
||||
'Cannot assign `foo` because it is neither a @depends nor a '
|
||||
'@template', str(e.exception))
|
||||
self.assertEquals(e.exception.message,
|
||||
'Cannot assign `foo` because it is neither a '
|
||||
'@depends nor a @template')
|
||||
|
||||
def test_depends_failures(self):
|
||||
with self.assertRaises(ConfigureError) as e:
|
||||
@ -1238,7 +1239,7 @@ class TestConfigure(unittest.TestCase):
|
||||
'''):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"@depends needs at least one argument")
|
||||
|
||||
with self.assertRaises(ConfigureError) as e:
|
||||
@ -1249,7 +1250,7 @@ class TestConfigure(unittest.TestCase):
|
||||
'''):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"'--with-foo' is not a known option. Maybe it's "
|
||||
"declared too late?")
|
||||
|
||||
@ -1261,7 +1262,7 @@ class TestConfigure(unittest.TestCase):
|
||||
'''):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"Option must not contain an '='")
|
||||
|
||||
with self.assertRaises(TypeError) as e:
|
||||
@ -1272,7 +1273,7 @@ class TestConfigure(unittest.TestCase):
|
||||
'''):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"Cannot use object of type 'int' as argument "
|
||||
"to @depends")
|
||||
|
||||
@ -1284,7 +1285,7 @@ class TestConfigure(unittest.TestCase):
|
||||
'''):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"Cannot decorate generator functions with @depends")
|
||||
|
||||
with self.assertRaises(TypeError) as e:
|
||||
@ -1293,7 +1294,7 @@ class TestConfigure(unittest.TestCase):
|
||||
'''):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"Unexpected type: 'int'")
|
||||
|
||||
with self.assertRaises(ConfigureError) as e:
|
||||
@ -1307,7 +1308,7 @@ class TestConfigure(unittest.TestCase):
|
||||
'''):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"The `foo` function may not be called")
|
||||
|
||||
with self.assertRaises(TypeError) as e:
|
||||
@ -1318,7 +1319,7 @@ class TestConfigure(unittest.TestCase):
|
||||
'''):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"depends_impl() got an unexpected keyword argument 'foo'")
|
||||
|
||||
def test_depends_when(self):
|
||||
@ -1363,7 +1364,7 @@ class TestConfigure(unittest.TestCase):
|
||||
'''):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'@imports must appear after @template')
|
||||
|
||||
with self.assertRaises(ConfigureError) as e:
|
||||
@ -1376,7 +1377,7 @@ class TestConfigure(unittest.TestCase):
|
||||
'''):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'@imports must appear after @depends')
|
||||
|
||||
for import_ in (
|
||||
@ -1393,7 +1394,7 @@ class TestConfigure(unittest.TestCase):
|
||||
''' % import_):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(str(e.exception), "Unexpected type: 'int'")
|
||||
self.assertEquals(e.exception.message, "Unexpected type: 'int'")
|
||||
|
||||
with self.assertRaises(TypeError) as e:
|
||||
with self.moz_configure('''
|
||||
@ -1404,7 +1405,7 @@ class TestConfigure(unittest.TestCase):
|
||||
'''):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(str(e.exception), "Unexpected type: 'int'")
|
||||
self.assertEquals(e.exception.message, "Unexpected type: 'int'")
|
||||
|
||||
with self.assertRaises(ValueError) as e:
|
||||
with self.moz_configure('''
|
||||
@ -1414,7 +1415,7 @@ class TestConfigure(unittest.TestCase):
|
||||
'''):
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"Invalid argument to @imports: 'os*'")
|
||||
|
||||
def test_only_when(self):
|
||||
@ -1469,7 +1470,7 @@ class TestConfigure(unittest.TestCase):
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
self.get_config(['--foo'])
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'--foo is not available in this configuration')
|
||||
|
||||
# Cannot depend on an option defined in a only_when block, because we
|
||||
@ -1480,7 +1481,7 @@ class TestConfigure(unittest.TestCase):
|
||||
with self.assertRaises(ConfigureError) as e:
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'@depends function needs the same `when` as '
|
||||
'options it depends on')
|
||||
|
||||
@ -1497,7 +1498,7 @@ class TestConfigure(unittest.TestCase):
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
self.get_config()
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'--foo is not available in this configuration')
|
||||
|
||||
# And similarly doesn't fail when the condition is true.
|
||||
|
@ -68,67 +68,67 @@ class TestOption(unittest.TestCase):
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--option', nargs=0, default=('a',))
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"The given `default` doesn't satisfy `nargs`")
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--option', nargs=1, default=())
|
||||
self.assertEquals(
|
||||
str(e.exception),
|
||||
e.exception.message,
|
||||
'default must be a bool, a string or a tuple of strings')
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--option', nargs=1, default=True)
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"The given `default` doesn't satisfy `nargs`")
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--option', nargs=1, default=('a', 'b'))
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"The given `default` doesn't satisfy `nargs`")
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--option', nargs=2, default=())
|
||||
self.assertEquals(
|
||||
str(e.exception),
|
||||
e.exception.message,
|
||||
'default must be a bool, a string or a tuple of strings')
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--option', nargs=2, default=True)
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"The given `default` doesn't satisfy `nargs`")
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--option', nargs=2, default=('a',))
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"The given `default` doesn't satisfy `nargs`")
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--option', nargs='?', default=('a', 'b'))
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"The given `default` doesn't satisfy `nargs`")
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--option', nargs='+', default=())
|
||||
self.assertEquals(
|
||||
str(e.exception),
|
||||
e.exception.message,
|
||||
'default must be a bool, a string or a tuple of strings')
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--option', nargs='+', default=True)
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"The given `default` doesn't satisfy `nargs`")
|
||||
|
||||
# --disable options with a nargs value that requires at least one
|
||||
# argument need to be given a default.
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--disable-option', nargs=1)
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"The given `default` doesn't satisfy `nargs`")
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--disable-option', nargs='+')
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"The given `default` doesn't satisfy `nargs`")
|
||||
|
||||
# Test nargs inference from default value
|
||||
@ -188,38 +188,38 @@ class TestOption(unittest.TestCase):
|
||||
def test_option_choices(self):
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--option', nargs=3, choices=('a', 'b'))
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'Not enough `choices` for `nargs`')
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--without-option', nargs=1, choices=('a', 'b'))
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'A `default` must be given along with `choices`')
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--without-option', nargs='+', choices=('a', 'b'))
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'A `default` must be given along with `choices`')
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--without-option', default='c', choices=('a', 'b'))
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"The `default` value must be one of 'a', 'b'")
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--without-option', default=('a', 'c',), choices=('a', 'b'))
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"The `default` value must be one of 'a', 'b'")
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--without-option', default=('c',), choices=('a', 'b'))
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"The `default` value must be one of 'a', 'b'")
|
||||
|
||||
option = Option('--with-option', nargs='+', choices=('a', 'b'))
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
option.get_value('--with-option=c')
|
||||
self.assertEquals(str(e.exception), "'c' is not one of 'a', 'b'")
|
||||
self.assertEquals(e.exception.message, "'c' is not one of 'a', 'b'")
|
||||
|
||||
value = option.get_value('--with-option=b,a')
|
||||
self.assertTrue(value)
|
||||
@ -229,7 +229,7 @@ class TestOption(unittest.TestCase):
|
||||
choices=('a', 'b'))
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
option.get_value('--with-option=c')
|
||||
self.assertEquals(str(e.exception), "'c' is not one of 'a', 'b'")
|
||||
self.assertEquals(e.exception.message, "'c' is not one of 'a', 'b'")
|
||||
|
||||
value = option.get_value('--with-option=b,a')
|
||||
self.assertTrue(value)
|
||||
@ -263,18 +263,18 @@ class TestOption(unittest.TestCase):
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
option.get_value('--with-option=-e')
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"'e' is not one of 'a', 'b', 'c', 'd'")
|
||||
|
||||
# Other "not a choice" errors.
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
option.get_value('--with-option=+e')
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"'e' is not one of 'a', 'b', 'c', 'd'")
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
option.get_value('--with-option=e')
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"'e' is not one of 'a', 'b', 'c', 'd'")
|
||||
|
||||
def test_option_value_compare(self):
|
||||
@ -365,13 +365,13 @@ class TestOption(unittest.TestCase):
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
option.get_value('--%s' % name)
|
||||
if nargs == 1:
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'--%s takes 1 value' % name)
|
||||
elif nargs == '+':
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'--%s takes 1 or more values' % name)
|
||||
else:
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'--%s takes 2 values' % name)
|
||||
|
||||
value = option.get_value('')
|
||||
@ -399,10 +399,10 @@ class TestOption(unittest.TestCase):
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
option.get_value('--%s=' % name)
|
||||
if disabled:
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'Cannot pass a value to --%s' % name)
|
||||
else:
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'--%s takes %d values' % (name, nargs))
|
||||
|
||||
if nargs in (1, '?', '*', '+') and not disabled:
|
||||
@ -413,10 +413,10 @@ class TestOption(unittest.TestCase):
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
option.get_value('--%s=foo' % name)
|
||||
if disabled:
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'Cannot pass a value to --%s' % name)
|
||||
else:
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'--%s takes %d values' % (name, nargs))
|
||||
|
||||
if nargs in (2, '*', '+') and not disabled:
|
||||
@ -427,13 +427,13 @@ class TestOption(unittest.TestCase):
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
option.get_value('--%s=foo,bar' % name, 'option')
|
||||
if disabled:
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'Cannot pass a value to --%s' % name)
|
||||
elif nargs == '?':
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'--%s takes 0 or 1 values' % name)
|
||||
else:
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'--%s takes %d value%s'
|
||||
% (name, nargs, 's' if nargs != 1 else ''))
|
||||
|
||||
@ -447,13 +447,13 @@ class TestOption(unittest.TestCase):
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
option.get_value('--%s' % name)
|
||||
if disabled:
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'Cannot pass a value to --%s' % name)
|
||||
elif nargs == '+':
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'--%s takes 1 or more values' % name)
|
||||
else:
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'--%s takes %d value%s'
|
||||
% (name, nargs, 's' if nargs != 1 else ''))
|
||||
|
||||
@ -480,7 +480,7 @@ class TestOption(unittest.TestCase):
|
||||
else:
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
option.get_value('MOZ_OPTION=1', 'environment')
|
||||
self.assertEquals(str(e.exception), 'MOZ_OPTION takes 2 values')
|
||||
self.assertEquals(e.exception.message, 'MOZ_OPTION takes 2 values')
|
||||
|
||||
if nargs in (1, '?', '*', '+') and not disabled:
|
||||
value = option.get_value('--%s=' % name, 'option')
|
||||
@ -490,10 +490,10 @@ class TestOption(unittest.TestCase):
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
option.get_value('--%s=' % name, 'option')
|
||||
if disabled:
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'Cannot pass a value to --%s' % name)
|
||||
else:
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'--%s takes %d values' % (name, nargs))
|
||||
|
||||
with self.assertRaises(AssertionError):
|
||||
@ -506,7 +506,7 @@ class TestOption(unittest.TestCase):
|
||||
else:
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
option.get_value('MOZ_OPTION=foo', 'environment')
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'MOZ_OPTION takes %d values' % nargs)
|
||||
|
||||
if nargs in (2, '*', '+'):
|
||||
@ -517,10 +517,10 @@ class TestOption(unittest.TestCase):
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
option.get_value('MOZ_OPTION=foo,bar', 'environment')
|
||||
if nargs == '?':
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'MOZ_OPTION takes 0 or 1 values')
|
||||
else:
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'MOZ_OPTION takes %d value%s'
|
||||
% (nargs, 's' if nargs != 1 else ''))
|
||||
|
||||
@ -551,7 +551,7 @@ class TestOption(unittest.TestCase):
|
||||
else:
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
env_option.get_value('MOZ_OPTION=1', 'environment')
|
||||
self.assertEquals(str(e.exception), 'MOZ_OPTION takes 2 values')
|
||||
self.assertEquals(e.exception.message, 'MOZ_OPTION takes 2 values')
|
||||
|
||||
with self.assertRaises(AssertionError) as e:
|
||||
env_option.get_value('--%s' % name)
|
||||
@ -566,7 +566,7 @@ class TestOption(unittest.TestCase):
|
||||
else:
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
env_option.get_value('MOZ_OPTION=foo', 'environment')
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'MOZ_OPTION takes %d values' % nargs)
|
||||
|
||||
if nargs in (2, '*', '+'):
|
||||
@ -577,10 +577,10 @@ class TestOption(unittest.TestCase):
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
env_option.get_value('MOZ_OPTION=foo,bar', 'environment')
|
||||
if nargs == '?':
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'MOZ_OPTION takes 0 or 1 values')
|
||||
else:
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'MOZ_OPTION takes %d value%s'
|
||||
% (nargs, 's' if nargs != 1 else ''))
|
||||
|
||||
@ -606,14 +606,14 @@ class TestOption(unittest.TestCase):
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
option.get_value('--%s-option' % enable, 'option')
|
||||
if nargs == 1:
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'--%s-option takes 1 value' % enable)
|
||||
elif nargs == '+':
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'--%s-option takes 1 or more values'
|
||||
% enable)
|
||||
else:
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
'--%s-option takes 2 values' % enable)
|
||||
|
||||
def test_option_value_with(self):
|
||||
@ -622,12 +622,12 @@ class TestOption(unittest.TestCase):
|
||||
def test_option_value_invalid_nargs(self):
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--option', nargs='foo')
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"nargs must be a positive integer, '?', '*' or '+'")
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--option', nargs=-2)
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"nargs must be a positive integer, '?', '*' or '+'")
|
||||
|
||||
def test_option_value_nargs_1(self):
|
||||
@ -638,7 +638,7 @@ class TestOption(unittest.TestCase):
|
||||
# A default is required
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--disable-option', nargs=1)
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"The given `default` doesn't satisfy `nargs`")
|
||||
|
||||
def test_option_value_nargs_2(self):
|
||||
@ -649,7 +649,7 @@ class TestOption(unittest.TestCase):
|
||||
# A default is required
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--disable-option', nargs=2)
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"The given `default` doesn't satisfy `nargs`")
|
||||
|
||||
def test_option_value_nargs_0_or_1(self):
|
||||
@ -676,7 +676,7 @@ class TestOption(unittest.TestCase):
|
||||
# A default is required
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
Option('--disable-option', nargs='+')
|
||||
self.assertEquals(str(e.exception),
|
||||
self.assertEquals(e.exception.message,
|
||||
"The given `default` doesn't satisfy `nargs`")
|
||||
|
||||
|
||||
|
@ -9,10 +9,9 @@ import os
|
||||
import tempfile
|
||||
import textwrap
|
||||
import unittest
|
||||
import six
|
||||
import sys
|
||||
|
||||
from six import StringIO
|
||||
from StringIO import StringIO
|
||||
|
||||
from mozunit import main
|
||||
from mozpack import path as mozpath
|
||||
@ -438,8 +437,8 @@ class TestLogSubprocessOutput(unittest.TestCase):
|
||||
self.assertEquals(status, 0)
|
||||
quote_char = "'"
|
||||
if getpreferredencoding().lower() == 'utf-8':
|
||||
quote_char = '\u00B4'
|
||||
self.assertEquals(six.ensure_text(out.getvalue().strip()), quote_char)
|
||||
quote_char = '\u00B4'.encode('utf-8')
|
||||
self.assertEquals(out.getvalue().strip(), quote_char)
|
||||
|
||||
|
||||
class TestVersion(unittest.TestCase):
|
||||
|
@ -1,10 +1,6 @@
|
||||
[DEFAULT]
|
||||
subsuite = mozbuild
|
||||
|
||||
[configure/test_checks_configure.py]
|
||||
[configure/test_configure.py]
|
||||
[configure/test_options.py]
|
||||
[configure/test_util.py]
|
||||
[controller/test_ccachestats.py]
|
||||
[controller/test_clobber.py]
|
||||
[test_artifact_cache.py]
|
||||
|
@ -19,12 +19,16 @@ skip-if = (os == "win")
|
||||
[codecoverage/test_lcov_rewrite.py]
|
||||
[compilation/test_warnings.py]
|
||||
[configure/lint.py]
|
||||
[configure/test_checks_configure.py]
|
||||
[configure/test_compile_checks.py]
|
||||
[configure/test_configure.py]
|
||||
[configure/test_lint.py]
|
||||
[configure/test_moz_configure.py]
|
||||
[configure/test_options.py]
|
||||
[configure/test_toolchain_configure.py]
|
||||
[configure/test_toolchain_helpers.py]
|
||||
[configure/test_toolkit_moz_configure.py]
|
||||
[configure/test_util.py]
|
||||
[frontend/test_context.py]
|
||||
[frontend/test_emitter.py]
|
||||
[frontend/test_namespaces.py]
|
||||
|
Loading…
Reference in New Issue
Block a user