Bug 1345109 - Delete 'JS_STANDALONE' from EmptyConfig when generating test metadata. r=mshal, a=test-only
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Tue, 07 Mar 2017 10:56:22 -0500
changeset 395429 65d80cd8f42280ebcea7e741714e4e3612c7076a
parent 395428 23456e5fa774fa0226e860454fd73fc5a6a99a24
child 395430 47b5215fc8ad2b5f610872dffb411b82c07c0b60
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmshal, test-only
bugs1345109
milestone54.0a2
Bug 1345109 - Delete 'JS_STANDALONE' from EmptyConfig when generating test metadata. r=mshal, a=test-only 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.
+        substs = EmptyConfig.default_substs
+        if 'JS_STANDALONE' in substs:
+            del substs['JS_STANDALONE']
+
+        config = EmptyConfig(build_obj.topsrcdir, substs)
         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,33 @@ 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_substs = {
+        # 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, substs=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',
-        })
+        self.substs = self.PopulateOnGetDict(EmptyValue, substs or self.default_substs)
         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