Bug 1446019 - Improve error message for LOCAL_INCLUDES pointing to topobjdir; r?build-peer draft
authorGregory Szorc <gps@mozilla.com>
Thu, 15 Mar 2018 09:43:35 -0700
changeset 768039 787050a1a6ae71d706818b867ee4b26de2546f99
parent 767919 fcb11e93adf57210167de0b27b15433e9c3f45e4
push id102788
push userbmo:gps@mozilla.com
push dateThu, 15 Mar 2018 16:43:57 +0000
reviewersbuild-peer
bugs1446019
milestone61.0a1
Bug 1446019 - Improve error message for LOCAL_INCLUDES pointing to topobjdir; r?build-peer The old message is ambiguous as to why it failed. The new one tells you why and hopefully gives you enough info to fix it. MozReview-Commit-ID: 9cBpYLpCFmt
python/mozbuild/mozbuild/frontend/emitter.py
python/mozbuild/mozbuild/test/frontend/test_emitter.py
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -1125,18 +1125,18 @@ class TreeMetadataEmitter(LoggingMixin):
             if (not isinstance(local_include, ObjDirPath) and
                     not os.path.exists(full_path)):
                 raise SandboxValidationError('Path specified in LOCAL_INCLUDES '
                     'does not exist: %s (resolved to %s)' % (local_include,
                     full_path), context)
             if (full_path == context.config.topsrcdir or
                     full_path == context.config.topobjdir):
                 raise SandboxValidationError('Path specified in LOCAL_INCLUDES '
-                    'is not allowed: %s (resolved to %s)' % (local_include,
-                    full_path), context)
+                    '(%s) resolves to the topsrcdir or topobjdir (%s), which is '
+                    'not allowed' % (local_include, full_path), context)
             include_obj = LocalInclude(context, local_include)
             local_includes.append(include_obj.path.full_path)
             yield include_obj
 
         computed_flags.resolve_flags('LOCAL_INCLUDES', ['-I%s' % p for p in local_includes])
         computed_as_flags.resolve_flags('LOCAL_INCLUDES', ['-I%s' % p for p in local_includes])
         computed_host_flags.resolve_flags('LOCAL_INCLUDES', ['-I%s' % p for p in local_includes])
 
--- a/python/mozbuild/mozbuild/test/frontend/test_emitter.py
+++ b/python/mozbuild/mozbuild/test/frontend/test_emitter.py
@@ -1000,24 +1000,26 @@ class TestEmitterBasic(unittest.TestCase
         self.assertEqual(local_includes, expected)
 
     def test_local_includes_invalid(self):
         """Test that invalid LOCAL_INCLUDES are properly detected."""
         reader = self.reader('local_includes-invalid/srcdir')
 
         with self.assertRaisesRegexp(
                 SandboxValidationError,
-                'Path specified in LOCAL_INCLUDES is not allowed:'):
+                'Path specified in LOCAL_INCLUDES.*resolves to the '
+                'topsrcdir or topobjdir'):
             objs = self.read_topsrcdir(reader)
 
         reader = self.reader('local_includes-invalid/objdir')
 
         with self.assertRaisesRegexp(
                 SandboxValidationError,
-                'Path specified in LOCAL_INCLUDES is not allowed:'):
+                'Path specified in LOCAL_INCLUDES.*resolves to the '
+                'topsrcdir or topobjdir'):
             objs = self.read_topsrcdir(reader)
 
     def test_generated_includes(self):
         """Test that GENERATED_INCLUDES is emitted correctly."""
         reader = self.reader('generated_includes')
         objs = self.read_topsrcdir(reader)
 
         generated_includes = [o.path for o in objs if isinstance(o, LocalInclude)]