Bug 1252798 - Add a hack to stop processing after test manifests are read; r?chmanchester draft
authorGregory Szorc <gps@mozilla.com>
Wed, 02 Mar 2016 12:04:01 -0800
changeset 336176 bde3edb86279d003a64ee8985e429f735d4dedd1
parent 335982 eb25b90a05c194bfd4f498ff3ffee7440f85f1cd
child 515339 f8ac9596226b9e19e1bb02d22184aba749f9f960
push id12007
push usergszorc@mozilla.com
push dateWed, 02 Mar 2016 20:04:20 +0000
reviewerschmanchester
bugs1252798, 1203266
milestone47.0a1
Bug 1252798 - Add a hack to stop processing after test manifests are read; r?chmanchester This is a hack. The tests manifests should be readable in the reader layer. But we have this nasty interplay between the reader and emitter causing all kinds of pain. See also bug 1203266. MozReview-Commit-ID: 4W2QdCmaDMJ
python/mozbuild/mozbuild/frontend/emitter.py
python/mozbuild/mozbuild/frontend/reader.py
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -689,20 +689,25 @@ class TreeMetadataEmitter(LoggingMixin):
                     yield cls(*arglist)
 
         for f, flags in all_flags.iteritems():
             if flags.flags:
                 ext = mozpath.splitext(f)[1]
                 yield PerSourceFlag(context, f, flags.flags)
 
 
-    def emit_from_context(self, context):
+    def emit_from_context(self, context, reading_test_manifests=False):
         """Convert a Context to tree metadata objects.
 
         This is a generator of mozbuild.frontend.data.ContextDerived instances.
+
+        If ``reading_test_manifests`` is True, we short circuit after test
+        manifests are read. It is meant to be used as a hack for moz.build
+        file reading mode, which gets test metadata from emitter because the
+        abstraction is wrong.
         """
 
         # We only want to emit an InstallationTarget if one of the consulted
         # variables is defined. Later on, we look up FINAL_TARGET, which has
         # the side-effect of populating it. So, we need to do this lookup
         # early.
         if any(k in context for k in ('FINAL_TARGET', 'XPI_NAME', 'DIST_SUBDIR')):
             yield InstallationTarget(context)
@@ -899,16 +904,20 @@ class TreeMetadataEmitter(LoggingMixin):
                                                    mozpath.basename(c)))
 
         for obj in self._handle_linkables(context, passthru):
             yield obj
 
         for obj in self._process_test_manifests(context):
             yield obj
 
+        # Early return when all we care about is test manifests.
+        if reading_test_manifests:
+            return
+
         for obj in self._process_jar_manifests(context):
             yield obj
 
         for name, jar in context.get('JAVA_JAR_TARGETS', {}).items():
             yield ContextWrapped(context, jar)
 
         for name, data in context.get('ANDROID_ECLIPSE_PROJECT_TARGETS', {}).items():
             yield ContextWrapped(context, data)
--- a/python/mozbuild/mozbuild/frontend/reader.py
+++ b/python/mozbuild/mozbuild/frontend/reader.py
@@ -1414,17 +1414,18 @@ class TestContextReader(object):
         for ctx in ctxs:
             test_context = Context(VARIABLES, self.config)
             test_context.main_path = ctx.main_path
 
             # Clone just the keys that will result in test manifests.
             manifest_keys = [key for key in ctx if key in self._test_manifest_contexts]
             for key in manifest_keys:
                 test_context[key] = ctx[key]
-            for obj in emitter.emit_from_context(test_context):
+            for obj in emitter.emit_from_context(test_context,
+                                                 reading_test_manifests=True):
                 if isinstance(obj, TestManifest):
                     for t in obj.tests:
                         if 'relpath' not in t:
                             # wpt manifests do not generate relpaths (bug 1207678).
                             t['relpath'] = mozpath.relpath(t['path'],
                                                            self.config.topsrcdir)
                         # Pull in the entire directory of tests.
                         result_context.test_files.add(mozpath.dirname(t['relpath']) + '/**')