Bug 1266343 - Use an empty mozconfig from the source directory. r?chmanchester draft
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 20 Apr 2016 14:03:01 +0900
changeset 354785 d5fc3fc9d3437bc96d5a0d57ecede8bc215637a0
parent 354784 93183146ae097d21ace6b1b1392bfa4bb60213c6
child 354786 41a964b1a8a051d78ae98198925638478aecd5d1
push id16148
push userbmo:mh+mozilla@glandium.org
push dateThu, 21 Apr 2016 12:30:02 +0000
reviewerschmanchester
bugs1266343
milestone48.0a1
Bug 1266343 - Use an empty mozconfig from the source directory. r?chmanchester When configure unit tests use an empty mozconfig, instead of creating an empty temporary file, use an empty mozconfig from the source directory.
python/mozbuild/mozbuild/test/configure/common.py
python/mozbuild/mozbuild/test/configure/data/empty_mozconfig
--- a/python/mozbuild/mozbuild/test/configure/common.py
+++ b/python/mozbuild/mozbuild/test/configure/common.py
@@ -165,19 +165,23 @@ class BaseConfigureTest(unittest.TestCas
     def config_sub(self, stdin, args):
         return 0, args[0], ''
 
     def get_sandbox(self, paths, config, args=[], environ={}, mozconfig='',
                     out=None):
         if not out:
             out = StringIO()
 
-        fh, mozconfig_path = tempfile.mkstemp()
-        os.write(fh, mozconfig)
-        os.close(fh)
+        if mozconfig:
+            fh, mozconfig_path = tempfile.mkstemp()
+            os.write(fh, mozconfig)
+            os.close(fh)
+        else:
+            mozconfig_path = os.path.join(os.path.dirname(__file__), 'data',
+                                          'empty_mozconfig')
 
         try:
             environ = dict(
                 environ,
                 OLD_CONFIGURE=os.path.join(topsrcdir, 'old-configure'),
                 MOZCONFIG=mozconfig_path)
 
             paths = dict(paths)
@@ -187,9 +191,10 @@ class BaseConfigureTest(unittest.TestCas
             paths[mozpath.join(autoconf_dir, 'config.sub')] = self.config_sub
 
             sandbox = ConfigureTestSandbox(paths, config, environ,
                                            ['configure'] + args, out, out)
             sandbox.include_file(os.path.join(topsrcdir, 'moz.configure'))
 
             return sandbox
         finally:
-            os.remove(mozconfig_path)
+            if mozconfig:
+                os.remove(mozconfig_path)
new file mode 100644