Bug 1256571 - Rename ConfigureSandbox.exec_file to include_file. r?chmanchester draft
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 13 Apr 2016 08:42:17 +0900
changeset 350230 7857fbf1475a86db634486a33914218b98946114
parent 350229 ab826bf1ecb63997827c45e61aef9bcf15331381
child 350231 b30bf73443fb2b957846852a7c96ef1d6509a7b6
push id15274
push userbmo:mh+mozilla@glandium.org
push dateWed, 13 Apr 2016 01:01:28 +0000
reviewerschmanchester
bugs1256571
milestone48.0a1
Bug 1256571 - Rename ConfigureSandbox.exec_file to include_file. r?chmanchester
python/mozbuild/mozbuild/configure/__init__.py
python/mozbuild/mozbuild/test/configure/test_checks_configure.py
python/mozbuild/mozbuild/test/configure/test_configure.py
--- a/python/mozbuild/mozbuild/configure/__init__.py
+++ b/python/mozbuild/mozbuild/configure/__init__.py
@@ -164,19 +164,19 @@ class ConfigureSandbox(dict):
         if self._value_for(self._help_option):
             self._help = HelpFormatter(argv[0])
             self._help.add(self._help_option)
         elif moz_logger:
             handler = logging.FileHandler('config.log', mode='w', delay=True)
             handler.setFormatter(formatter)
             logger.addHandler(handler)
 
-    def exec_file(self, path):
-        '''Execute one file within the sandbox. Users of this class probably
-        want to use `run` instead.'''
+    def include_file(self, path):
+        '''Include one file in the sandbox. Users of this class probably want
+        to use `run` instead.'''
 
         if self._paths:
             path = mozpath.join(mozpath.dirname(self._paths[-1]), path)
             path = mozpath.normpath(path)
             if not mozpath.basedir(path, (mozpath.dirname(self._paths[0]),)):
                 raise ConfigureError(
                     'Cannot include `%s` because it is not in a subdirectory '
                     'of `%s`' % (path, mozpath.dirname(self._paths[0])))
@@ -194,17 +194,17 @@ class ConfigureSandbox(dict):
 
         exec(code, self)
 
         self._paths.pop(-1)
 
     def run(self, path):
         '''Executes the given file within the sandbox, and ensure the overall
         consistency of the executed script.'''
-        self.exec_file(path)
+        self.include_file(path)
 
         for option in self._options.itervalues():
             # All options must be referenced by some @depends function
             if option not in self._seen:
                 raise ConfigureError(
                     'Option `%s` is not handled ; reference it with a @depends'
                     % option.option
                 )
@@ -429,17 +429,17 @@ class ConfigureSandbox(dict):
         It is possible to use a @depends function as argument, in which case
         the result of the function is the file name to include. This latter
         feature is only really meant for --enable-application/--enable-project.
         '''
         what = self._resolve(what)
         if what:
             if not isinstance(what, types.StringTypes):
                 raise TypeError("Unexpected type: '%s'" % type(what).__name__)
-            self.exec_file(what)
+            self.include_file(what)
 
     def template_impl(self, func):
         '''Implementation of @template.
         This function is a decorator. Template functions are called
         immediately. They are altered so that their global namespace exposes
         a limited set of functions from os.path, as well as `depends` and
         `option`.
         Templates allow to simplify repetitive constructs, or to implement
--- a/python/mozbuild/mozbuild/test/configure/test_checks_configure.py
+++ b/python/mozbuild/mozbuild/test/configure/test_checks_configure.py
@@ -51,17 +51,17 @@ class FindProgramSandbox(ConfigureSandbo
         super(FindProgramSandbox, self).__setitem__(key, value)
 
 
 class TestChecksConfigure(unittest.TestCase):
     def test_checking(self):
         out = StringIO()
         sandbox = FindProgramSandbox({}, stdout=out, stderr=out)
         base_dir = os.path.join(topsrcdir, 'build', 'moz.configure')
-        sandbox.exec_file(os.path.join(base_dir, 'checks.configure'))
+        sandbox.include_file(os.path.join(base_dir, 'checks.configure'))
 
         exec(textwrap.dedent('''
             @checking('for a thing')
             def foo(value):
                 return value
         '''), sandbox)
 
         foo = sandbox['foo']
@@ -153,18 +153,18 @@ class TestChecksConfigure(unittest.TestC
         self.assertEqual(out.getvalue(), 'checking for a thing... foo bar\n')
 
     def get_result(self, command='', args=[], environ={},
                    prog='/bin/configure'):
         config = {}
         out = StringIO()
         sandbox = FindProgramSandbox(config, environ, [prog] + args, out, out)
         base_dir = os.path.join(topsrcdir, 'build', 'moz.configure')
-        sandbox.exec_file(os.path.join(base_dir, 'util.configure'))
-        sandbox.exec_file(os.path.join(base_dir, 'checks.configure'))
+        sandbox.include_file(os.path.join(base_dir, 'util.configure'))
+        sandbox.include_file(os.path.join(base_dir, 'checks.configure'))
 
         status = 0
         try:
             exec(command, sandbox)
         except SystemExit as e:
             status = e.code
 
         return config, out.getvalue(), status
--- a/python/mozbuild/mozbuild/test/configure/test_configure.py
+++ b/python/mozbuild/mozbuild/test/configure/test_configure.py
@@ -367,17 +367,17 @@ class TestConfigure(unittest.TestCase):
         self.assertIn('PLATFORM', config)
         self.assertEquals(config['PLATFORM'], sys.platform)
 
     def test_decorators(self):
         config = {}
         out = StringIO()
         sandbox = ConfigureSandbox(config, {}, [], out, out)
 
-        sandbox.exec_file(mozpath.join(test_data_path, 'decorators.configure'))
+        sandbox.include_file(mozpath.join(test_data_path, 'decorators.configure'))
 
         self.assertNotIn('FOO', sandbox)
         self.assertNotIn('BAR', sandbox)
         self.assertNotIn('QUX', sandbox)
 
     def test_set_config(self):
         def get_config(*args):
             return self.get_config(*args, configure='set_config.configure')