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.
--- 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)