Bug 1345109 - Delete 'JS_STANDALONE' from EmptyConfig when generating test metadata, r?mshal draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Tue, 07 Mar 2017 10:56:22 -0500
changeset 494764 b06de2fb0afa975777157868ee12d8e0ccfd30a9
parent 494763 5a342ce8fd1230a65cf6cd16892da6a815fa1d31
child 548188 c5dccbad22ce51456328ca1bb211c2576e107e1d
push id48122
push userahalberstadt@mozilla.com
push dateTue, 07 Mar 2017 19:23:50 +0000
reviewersmshal
bugs1345109
milestone55.0a1
Bug 1345109 - Delete 'JS_STANDALONE' from EmptyConfig when generating test metadata, r?mshal EmptyConfig objects set JS_STANDALONE=1 by default. However, test tasks that need to run without an objdir need to be behind an "if not CONFIG['JS_STANDALONE']" condition to avoid causing bustage to sm-pkg task (js packaging). This patch explicitly deletes that default value, only when generating the TestManifestBackend. Ideally, the js/src packaging should have their own moz.build instead of re-using the root moz.build. But this is an easier fix in the short term to get the marionette-harness tests working again. MozReview-Commit-ID: 26lHLY6WlZK
build/gen_test_backend.py
moz.build
python/mozbuild/mozbuild/frontend/reader.py
--- a/build/gen_test_backend.py
+++ b/build/gen_test_backend.py
@@ -11,17 +11,24 @@ from mozbuild.frontend.reader import Bui
 
 
 def gen_test_backend():
     build_obj = MozbuildObject.from_environment()
     try:
         config = build_obj.config_environment
     except BuildEnvironmentNotFoundException:
         print("No build detected, test metadata may be incomplete.")
-        config = EmptyConfig(build_obj.topsrcdir)
+
+        # If 'JS_STANDALONE' is set, tests that don't require an objdir won't
+        # be picked up due to bug 1345209.
+        config = EmptyConfig.default_config
+        if 'JS_STANDALONE' in config:
+            del config['JS_STANDALONE']
+
+        config = EmptyConfig(build_obj.topsrcdir, config)
         config.topobjdir = build_obj.topobjdir
 
     reader = BuildReader(config)
     emitter = TreeMetadataEmitter(config)
     backend = TestManifestBackend(config)
 
     context = reader.read_topsrcdir()
     data = emitter.emit(context, emitfn=emitter._process_test_manifests)
--- a/moz.build
+++ b/moz.build
@@ -21,16 +21,21 @@ if CONFIG['ENABLE_CLANG_PLUGIN']:
 DIRS += [
     'config',
     'python',
     'taskcluster',
     'testing/mozbase',
 ]
 
 if not CONFIG['JS_STANDALONE']:
+    # These python manifests are included here so they get picked up without an objdir
+    PYTHON_UNITTEST_MANIFESTS += [
+        'testing/marionette/harness/marionette_harness/tests/harness_unit/python.ini',
+    ]
+
     CONFIGURE_SUBST_FILES += [
         'tools/update-packaging/Makefile',
     ]
     CONFIGURE_DEFINE_FILES += [
         'mozilla-config.h',
     ]
     EXPORTS += [
         '!buildid.h',
@@ -80,17 +85,11 @@ if CONFIG['COMPILE_ENVIRONMENT']:
     DIRS += ['js/src']
 else:
     TEST_DIRS += ['js/src/tests']
 
 if not CONFIG['JS_STANDALONE'] and CONFIG['MOZ_BUILD_APP']:
     # Bring in the configuration for the configured application.
     include('/' + CONFIG['MOZ_BUILD_APP'] + '/app.mozbuild')
 
-if not CONFIG['JS_STANDALONE']:
-    # These python manifests are included here so they get picked up without an objdir
-    PYTHON_UNITTEST_MANIFESTS += [
-        'testing/marionette/harness/marionette_harness/tests/harness_unit/python.ini',
-    ]
-
 CONFIGURE_SUBST_FILES += ['.cargo/config']
 
 include('build/templates.mozbuild')
--- a/python/mozbuild/mozbuild/frontend/reader.py
+++ b/python/mozbuild/mozbuild/frontend/reader.py
@@ -108,31 +108,34 @@ class EmptyConfig(object):
         """A variation on ReadOnlyDefaultDict that populates during .get().
 
         This variation is needed because CONFIG uses .get() to access members.
         Without it, None (instead of our EmptyValue types) would be returned.
         """
         def get(self, key, default=None):
             return self[key]
 
-    def __init__(self, topsrcdir):
+    default_config = {
+        # These 2 variables are used semi-frequently and it isn't worth
+        # changing all the instances.
+        b'MOZ_APP_NAME': b'empty',
+        b'MOZ_CHILD_PROCESS_NAME': b'empty',
+        # Set manipulations are performed within the moz.build files. But
+        # set() is not an exposed symbol, so we can't create an empty set.
+        b'NECKO_PROTOCOLS': set(),
+        # Needed to prevent js/src's config.status from loading.
+        b'JS_STANDALONE': b'1',
+    }
+
+    def __init__(self, topsrcdir, config=None):
         self.topsrcdir = topsrcdir
         self.topobjdir = ''
 
-        self.substs = self.PopulateOnGetDict(EmptyValue, {
-            # These 2 variables are used semi-frequently and it isn't worth
-            # changing all the instances.
-            b'MOZ_APP_NAME': b'empty',
-            b'MOZ_CHILD_PROCESS_NAME': b'empty',
-            # Set manipulations are performed within the moz.build files. But
-            # set() is not an exposed symbol, so we can't create an empty set.
-            b'NECKO_PROTOCOLS': set(),
-            # Needed to prevent js/src's config.status from loading.
-            b'JS_STANDALONE': b'1',
-        })
+        config = config or self.default_config
+        self.substs = self.PopulateOnGetDict(EmptyValue, config)
         udict = {}
         for k, v in self.substs.items():
             if isinstance(v, str):
                 udict[k.decode('utf-8')] = v.decode('utf-8')
             else:
                 udict[k] = v
         self.substs_unicode = self.PopulateOnGetDict(EmptyValue, udict)
         self.defines = self.substs