зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1266343 - Use mozbuild.util.exec_ in the various configure tests. r=chmanchester
Because some older python 2.7 versions throw bogus errors when using the exec statement as a function, use the function we added in bug 1264831 everywhere we use exec in the various configure tests. It doesn't take much to trigger them, and the following changes ends up doing exactly that.
This commit is contained in:
Родитель
ed674372da
Коммит
24fc0c73b9
|
@ -15,6 +15,7 @@ from mozbuild.configure import (
|
|||
ConfigureError,
|
||||
ConfigureSandbox,
|
||||
)
|
||||
from mozbuild.util import exec_
|
||||
|
||||
from buildconfig import topsrcdir
|
||||
|
||||
|
@ -58,7 +59,7 @@ class TestChecksConfigure(unittest.TestCase):
|
|||
base_dir = os.path.join(topsrcdir, 'build', 'moz.configure')
|
||||
sandbox.include_file(os.path.join(base_dir, 'checks.configure'))
|
||||
|
||||
exec(textwrap.dedent('''
|
||||
exec_(textwrap.dedent('''
|
||||
@checking('for a thing')
|
||||
def foo(value):
|
||||
return value
|
||||
|
@ -88,7 +89,7 @@ class TestChecksConfigure(unittest.TestCase):
|
|||
|
||||
# When the function given to checking does nothing interesting, the
|
||||
# behavior is not altered
|
||||
exec(textwrap.dedent('''
|
||||
exec_(textwrap.dedent('''
|
||||
@checking('for a thing', lambda x: x)
|
||||
def foo(value):
|
||||
return value
|
||||
|
@ -117,7 +118,7 @@ class TestChecksConfigure(unittest.TestCase):
|
|||
foo(data)
|
||||
self.assertEqual(out.getvalue(), 'checking for a thing... %r\n' % data)
|
||||
|
||||
exec(textwrap.dedent('''
|
||||
exec_(textwrap.dedent('''
|
||||
def munge(x):
|
||||
if not x:
|
||||
return 'not found'
|
||||
|
@ -163,7 +164,7 @@ class TestChecksConfigure(unittest.TestCase):
|
|||
|
||||
status = 0
|
||||
try:
|
||||
exec(command, sandbox)
|
||||
exec_(command, sandbox)
|
||||
sandbox.run()
|
||||
except SystemExit as e:
|
||||
status = e.code
|
||||
|
|
|
@ -24,6 +24,7 @@ from mozbuild.configure import (
|
|||
ConfigureError,
|
||||
ConfigureSandbox,
|
||||
)
|
||||
from mozbuild.util import exec_
|
||||
|
||||
import mozpack.path as mozpath
|
||||
|
||||
|
@ -244,7 +245,7 @@ class TestConfigure(unittest.TestCase):
|
|||
sandbox = ConfigureSandbox(config, {}, [], out, out)
|
||||
|
||||
with self.assertRaises(ImportError):
|
||||
exec(textwrap.dedent('''
|
||||
exec_(textwrap.dedent('''
|
||||
@template
|
||||
def foo():
|
||||
import sys
|
||||
|
@ -252,7 +253,7 @@ class TestConfigure(unittest.TestCase):
|
|||
sandbox
|
||||
)
|
||||
|
||||
exec(textwrap.dedent('''
|
||||
exec_(textwrap.dedent('''
|
||||
@template
|
||||
@imports('sys')
|
||||
def foo():
|
||||
|
@ -262,7 +263,7 @@ class TestConfigure(unittest.TestCase):
|
|||
|
||||
self.assertIs(sandbox['foo'](), sys)
|
||||
|
||||
exec(textwrap.dedent('''
|
||||
exec_(textwrap.dedent('''
|
||||
@template
|
||||
@imports(_from='os', _import='path')
|
||||
def foo():
|
||||
|
@ -272,7 +273,7 @@ class TestConfigure(unittest.TestCase):
|
|||
|
||||
self.assertIs(sandbox['foo'](), os.path)
|
||||
|
||||
exec(textwrap.dedent('''
|
||||
exec_(textwrap.dedent('''
|
||||
@template
|
||||
@imports(_from='os', _import='path', _as='os_path')
|
||||
def foo():
|
||||
|
@ -282,7 +283,7 @@ class TestConfigure(unittest.TestCase):
|
|||
|
||||
self.assertIs(sandbox['foo'](), os.path)
|
||||
|
||||
exec(textwrap.dedent('''
|
||||
exec_(textwrap.dedent('''
|
||||
@template
|
||||
@imports('__builtin__')
|
||||
def foo():
|
||||
|
@ -293,7 +294,7 @@ class TestConfigure(unittest.TestCase):
|
|||
import __builtin__
|
||||
self.assertIs(sandbox['foo'](), __builtin__)
|
||||
|
||||
exec(textwrap.dedent('''
|
||||
exec_(textwrap.dedent('''
|
||||
@template
|
||||
@imports(_from='__builtin__', _import='open')
|
||||
def foo():
|
||||
|
@ -306,7 +307,7 @@ class TestConfigure(unittest.TestCase):
|
|||
f.close()
|
||||
|
||||
# This unlocks the sandbox
|
||||
exec(textwrap.dedent('''
|
||||
exec_(textwrap.dedent('''
|
||||
@template
|
||||
@imports(_import='__builtin__', _as='__builtins__')
|
||||
def foo():
|
||||
|
@ -317,7 +318,7 @@ class TestConfigure(unittest.TestCase):
|
|||
|
||||
self.assertIs(sandbox['foo'](), sys)
|
||||
|
||||
exec(textwrap.dedent('''
|
||||
exec_(textwrap.dedent('''
|
||||
@template
|
||||
@imports('__sandbox__')
|
||||
def foo():
|
||||
|
@ -327,7 +328,7 @@ class TestConfigure(unittest.TestCase):
|
|||
|
||||
self.assertIs(sandbox['foo'](), sandbox)
|
||||
|
||||
exec(textwrap.dedent('''
|
||||
exec_(textwrap.dedent('''
|
||||
@template
|
||||
@imports(_import='__sandbox__', _as='s')
|
||||
def foo():
|
||||
|
|
Загрузка…
Ссылка в новой задаче