Bug 927143 - Reject srcdir == objdir build configurations; r=glandium
authorGregory Szorc <gps@mozilla.com>
Fri, 18 Oct 2013 09:25:53 -0700
changeset 166129 534e39d2935927e4ac8286ed6104f2f78f9d1af6
parent 166118 48932e8aa16206d69a1b0f738fcce733c8b3599a
child 166130 04a1e2c324e806233e591bc1caf0f184a68027c7
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs927143
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 927143 - Reject srcdir == objdir build configurations; r=glandium
python/mozbuild/mozbuild/base.py
python/mozbuild/mozbuild/test/test_base.py
--- a/python/mozbuild/mozbuild/base.py
+++ b/python/mozbuild/mozbuild/base.py
@@ -179,16 +179,21 @@ class MozbuildObject(ProcessExecutionMix
                 mozilla_dir)):
 
                 raise ObjdirMismatchException(topobjdir, config_topobjdir)
 
         topobjdir = topobjdir or config_topobjdir
         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)
 
     @staticmethod
     def resolve_mozconfig_topobjdir(topsrcdir, mozconfig, default=None):
         topobjdir = mozconfig['topobjdir'] or default
         if not topobjdir:
--- a/python/mozbuild/mozbuild/test/test_base.py
+++ b/python/mozbuild/mozbuild/test/test_base.py
@@ -13,16 +13,17 @@ import unittest
 
 from mozfile.mozfile import NamedTemporaryFile
 
 from mozunit import main
 
 from mach.logging import LoggingManager
 
 from mozbuild.base import (
+    BadEnvironmentException,
     MachCommandBase,
     MozbuildObject,
     PathArgument,
 )
 
 from mozbuild.backend.configenvironment import ConfigEnvironment
 
 
@@ -207,16 +208,36 @@ class TestMozbuildObject(unittest.TestCa
             o = MachCommandBase(context)
 
             self.assertEqual(o.topobjdir, topobjdir)
             self.assertEqual(o.topsrcdir, topsrcdir)
 
         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.
         base = self.get_base()
         result = base._config_guess
 
         self.assertIsNotNone(result)
         self.assertGreater(len(result), 0)