From 7badc78081e9b7255220076b9fb3aa04eced9846 Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Fri, 18 Oct 2013 09:25:53 -0700 Subject: [PATCH] Bug 927143 - Reject srcdir == objdir build configurations; r=glandium --- python/mozbuild/mozbuild/base.py | 5 +++++ python/mozbuild/mozbuild/test/test_base.py | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/python/mozbuild/mozbuild/base.py b/python/mozbuild/mozbuild/base.py index 974d702cfd0b..de0b7c593b58 100644 --- a/python/mozbuild/mozbuild/base.py +++ b/python/mozbuild/mozbuild/base.py @@ -184,6 +184,11 @@ class MozbuildObject(ProcessExecutionMixin): if topobjdir: topobjdir = os.path.normpath(topobjdir) + if topsrcdir == topobjdir: + raise BadEnvironmentException('The object directory appears ' + 'to be the same as your source directory (%s). This build ' + 'configuration is not supported.' % topsrcdir) + # If we can't resolve topobjdir, oh well. The constructor will figure # it out via config.guess. return cls(topsrcdir, None, None, topobjdir=topobjdir) diff --git a/python/mozbuild/mozbuild/test/test_base.py b/python/mozbuild/mozbuild/test/test_base.py index 088889214a7e..2b2b53a301d1 100644 --- a/python/mozbuild/mozbuild/test/test_base.py +++ b/python/mozbuild/mozbuild/test/test_base.py @@ -18,6 +18,7 @@ from mozunit import main from mach.logging import LoggingManager from mozbuild.base import ( + BadEnvironmentException, MachCommandBase, MozbuildObject, PathArgument, @@ -212,6 +213,26 @@ class TestMozbuildObject(unittest.TestCase): finally: shutil.rmtree(d) + @unittest.skip('Failing on buildbot.') + def test_objdir_is_srcdir_rejected(self): + """Ensure the srcdir configurations are rejected.""" + d = os.path.realpath(tempfile.mkdtemp()) + + try: + # The easiest way to do this is to create a mozinfo.json with data + # that will never happen. + mozinfo = os.path.join(d, 'mozinfo.json') + with open(mozinfo, 'wt') as fh: + json.dump({'topsrcdir': d}, fh) + + os.chdir(d) + + with self.assertRaises(BadEnvironmentException): + MozbuildObject.from_environment(detect_virtualenv_mozinfo=False) + + finally: + shutil.rmtree(d) + def test_config_guess(self): # It's difficult to test for exact values from the output of # config.guess because they vary depending on platform.