Bug 992983 - Build and upload the gtest libxul during test packaging. r=ted
authorChris Manchester <cmanchester@mozilla.com>
Thu, 16 Jul 2015 16:52:31 -0700
changeset 301877 3c6ab47a14b2e095b7247126d7366a518e6fdc03
parent 301876 d7cbb410ecd66c6bf5db94252d92ef5a34e93d14
child 301878 2924312b7d87f03e9cdf429e41b14c4199660540
push id8978
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 14:05:32 +0000
treeherdermozilla-aurora@b9a803752a2c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs992983
milestone46.0a1
Bug 992983 - Build and upload the gtest libxul during test packaging. r=ted
build/gen_test_packages_manifest.py
python/mozbuild/mozbuild/action/test_archive.py
testing/gtest/Makefile.in
testing/testsuite-targets.mk
toolkit/mozapps/installer/package-name.mk
toolkit/mozapps/installer/upload-files.mk
--- a/build/gen_test_packages_manifest.py
+++ b/build/gen_test_packages_manifest.py
@@ -14,43 +14,53 @@ ALL_HARNESSES = [
     'reftest',
     'webapprt',
     'xpcshell',
     'cppunittest',
     'jittest',
     'mozbase',
     'web-platform',
     'talos',
+    'gtest',
 ]
 
 PACKAGE_SPECIFIED_HARNESSES = [
     'cppunittest',
     'mochitest',
     'reftest',
     'xpcshell',
     'web-platform',
     'talos',
 ]
 
+# These packages are not present for every build configuration.
+OPTIONAL_PACKAGES = [
+    'gtest',
+]
+
 
 def parse_args():
     parser = ArgumentParser(description='Generate a test_packages.json file to tell automation which harnesses require which test packages.')
     parser.add_argument("--common", required=True,
                         action="store", dest="tests_common",
                         help="Name of the \"common\" archive, a package to be used by all harnesses.")
     parser.add_argument("--jsshell", required=True,
                         action="store", dest="jsshell",
                         help="Name of the jsshell zip.")
     parser.add_argument("--use-short-names", action="store_true",
                         help="Use short names for packages (target.$name.tests.zip "
                              "instead of $(PACKAGE_BASENAME).$name.tests.zip)")
     for harness in PACKAGE_SPECIFIED_HARNESSES:
         parser.add_argument("--%s" % harness, required=True,
                             action="store", dest=harness,
                             help="Name of the %s zip." % harness)
+    for harness in OPTIONAL_PACKAGES:
+        parser.add_argument("--%s" % harness, required=False,
+                            action="store", dest=harness,
+                            help="Name of the %s zip." % harness)
     parser.add_argument("--dest-file", required=True,
                         action="store", dest="destfile",
                         help="Path to the output file to be written.")
     return parser.parse_args()
 
 def generate_package_data(args):
     # Generate a dictionary mapping test harness names (exactly as they're known to
     # mozharness and testsuite-targets.mk, ideally) to the set of archive names that
@@ -61,18 +71,20 @@ def generate_package_data(args):
     tests_common = args.tests_common
     if args.use_short_names:
         tests_common = 'target.common.tests.zip'
 
     jsshell = args.jsshell
 
     harness_requirements = dict([(k, [tests_common]) for k in ALL_HARNESSES])
     harness_requirements['jittest'].append(jsshell)
-    for harness in PACKAGE_SPECIFIED_HARNESSES:
-        pkg_name = getattr(args, harness)
+    for harness in PACKAGE_SPECIFIED_HARNESSES + OPTIONAL_PACKAGES:
+        pkg_name = getattr(args, harness, None)
+        if pkg_name is None:
+            continue
         if args.use_short_names:
             pkg_name = 'target.%s.tests.zip' % harness
         harness_requirements[harness].append(pkg_name)
     return harness_requirements
 
 if __name__ == '__main__':
     args = parse_args()
     packages_data = generate_package_data(args)
--- a/python/mozbuild/mozbuild/action/test_archive.py
+++ b/python/mozbuild/mozbuild/action/test_archive.py
@@ -29,16 +29,17 @@ STAGE = mozpath.join(buildconfig.topobjd
 ARCHIVE_FILES = {
     'common': [
         {
             'source': STAGE,
             'base': '',
             'pattern': '**',
             'ignore': [
                 'cppunittest/**',
+                'gtest/**',
                 'mochitest/**',
                 'reftest/**',
                 'talos/**',
                 'web-platform/**',
                 'xpcshell/**',
             ],
         },
         {
@@ -148,16 +149,23 @@ ARCHIVE_FILES = {
         },
         {
             'source': buildconfig.topobjdir,
             'base': '',
             'pattern': 'mozinfo.json',
             'dest': 'cppunittest',
         },
     ],
+    'gtest': [
+        {
+            'source': STAGE,
+            'base': '',
+            'pattern': 'gtest/**',
+        },
+    ],
     'mochitest': [
         {
             'source': buildconfig.topobjdir,
             'base': '_tests/testing',
             'pattern': 'mochitest/**',
         },
         {
             'source': STAGE,
--- a/testing/gtest/Makefile.in
+++ b/testing/gtest/Makefile.in
@@ -2,44 +2,17 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # Avoid recursive make to avoid having to add files to the gtest/ subdirectory
 # (which is third-party code), and to make the build faster.
 
 include $(topsrcdir)/config/rules.mk
 
-# Bug 1028035: Linking xul-gtest.dll takes too long, so we disable GTest on
-# Windows PGO builds.
-ifeq (1_WINNT,$(MOZ_PGO)_$(OS_ARCH))
-SKIP_GTEST_DURING_MAKE_CHECK ?= 1
-endif
-
 ifeq (browser,$(MOZ_BUILD_APP))
 ifdef COMPILE_ENVIRONMENT
 gtest::
 	$(MAKE) -C $(DEPTH)/toolkit/library gtestxul
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 	$(MAKE) -C $(DEPTH)/browser/app repackage
 endif
-ifneq (1,$(SKIP_GTEST_DURING_MAKE_CHECK))
-check::
-	$(MAKE) -C $(DEPTH)/toolkit/library gtestxul
-ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
-	$(MAKE) -C $(DEPTH)/browser/app repackage
-	$(PYTHON) $(topsrcdir)/testing/gtest/rungtests.py \
-		--cwd=$(DEPTH)/_tests/gtest \
-		--xre-path=$(DIST)/$(MOZ_MACBUNDLE_NAME)/Contents/Resources \
-		--symbols-path=$(DIST)/crashreporter-symbols \
-		$(DIST)/$(MOZ_MACBUNDLE_NAME)/Contents/MacOS/$(MOZ_APP_NAME)$(BIN_SUFFIX)
-else
-	$(PYTHON) $(topsrcdir)/testing/gtest/rungtests.py \
-		--cwd=$(DEPTH)/_tests/gtest \
-		--xre-path=$(DIST)/bin \
-		--symbols-path=$(DIST)/crashreporter-symbols \
-		$(DIST)/bin/$(MOZ_APP_NAME)$(BIN_SUFFIX)
-endif
-else
-check::
-	echo GTest skipped during make check
 endif
 endif
-endif
--- a/testing/testsuite-targets.mk
+++ b/testing/testsuite-targets.mk
@@ -19,16 +19,30 @@ SYMBOLS_PATH := --symbols-path=$(DIST)/c
 # Usage: |make [TEST_PATH=...] [EXTRA_TEST_ARGS=...] mochitest*|.
 MOCHITESTS := mochitest-plain mochitest-chrome mochitest-devtools mochitest-a11y
 mochitest:: $(MOCHITESTS)
 
 ifndef TEST_PACKAGE_NAME
 TEST_PACKAGE_NAME := $(ANDROID_PACKAGE_NAME)
 endif
 
+# Linking xul-gtest.dll takes too long, so we disable GTest on
+# Windows PGO builds (bug 1028035).
+ifneq (1_WINNT,$(MOZ_PGO)_$(OS_ARCH))
+BUILD_GTEST=1
+endif
+
+ifdef MOZ_B2G
+BUILD_GTEST=
+endif
+
+ifeq ($(MOZ_BUILD_APP),mobile/android)
+BUILD_GTEST=
+endif
+
 RUN_MOCHITEST_B2G_DESKTOP = \
   rm -f ./$@.log && \
   $(PYTHON) _tests/testing/mochitest/runtestsb2g.py \
     --log-tbpl=./$@.log \
     --desktop --profile ${GAIA_PROFILE_DIR} \
     --failure-file=$(abspath _tests/testing/mochitest/makefailures.json) \
     $(EXTRA_TEST_ARGS) $(TEST_PATH_ARG)
 
@@ -394,16 +408,21 @@ TEST_PKGS := \
   cppunittest \
   mochitest \
   reftest \
   talos \
   web-platform \
   xpcshell \
   $(NULL)
 
+ifdef BUILD_GTEST
+stage-all: stage-gtest
+TEST_PKGS += gtest
+endif
+
 PKG_ARG = --$(1) '$(PKG_BASENAME).$(1).tests.zip'
 
 test-packages-manifest-tc:
 	@rm -f $(MOZ_TEST_PACKAGES_FILE_TC)
 	$(NSINSTALL) -D $(dir $(MOZ_TEST_PACKAGES_FILE_TC))
 	$(PYTHON) $(topsrcdir)/build/gen_test_packages_manifest.py \
       --jsshell $(JSSHELL_NAME) \
       --dest-file $(MOZ_TEST_PACKAGES_FILE_TC) \
@@ -477,16 +496,25 @@ ifeq ($(MOZ_BUILD_APP),mobile/android)
 endif
 
 stage-xpcshell: make-stage-dir
 	$(MAKE) -C $(DEPTH)/testing/xpcshell stage-package
 
 stage-jstests: make-stage-dir
 	$(MAKE) -C $(DEPTH)/js/src/tests stage-package
 
+stage-gtest: make-stage-dir
+# FIXME: (bug 1200311) We should be generating the gtest xul as part of the build.
+	$(MAKE) -C $(DEPTH)/testing/gtest gtest
+	$(NSINSTALL) -D $(PKG_STAGE)/gtest/gtest_bin
+	cp -RL $(DIST)/bin/gtest $(PKG_STAGE)/gtest/gtest_bin
+	cp -RL $(DEPTH)/_tests/gtest $(PKG_STAGE)
+	cp $(topsrcdir)/testing/gtest/rungtests.py $(PKG_STAGE)/gtest
+	cp $(DIST)/bin/dependentlibs.list.gtest $(PKG_STAGE)/gtest
+
 stage-android: make-stage-dir
 ifdef MOZ_ENABLE_SZIP
 # Tinderbox scripts are not unzipping everything, so the file needs to be in a directory it unzips
 	$(NSINSTALL) $(DIST)/host/bin/szip $(PKG_STAGE)/bin/host
 endif
 	$(NSINSTALL) $(DEPTH)/build/mobile/sutagent/android/sutAgentAndroid.apk $(PKG_STAGE)/bin
 	$(NSINSTALL) $(DEPTH)/build/mobile/sutagent/android/watcher/Watcher.apk $(PKG_STAGE)/bin
 	$(NSINSTALL) $(DEPTH)/build/mobile/sutagent/android/fencp/FenCP.apk $(PKG_STAGE)/bin
--- a/toolkit/mozapps/installer/package-name.mk
+++ b/toolkit/mozapps/installer/package-name.mk
@@ -138,16 +138,17 @@ MOZHARNESS_PACKAGE = mozharness.zip
 # Test package naming
 TEST_PACKAGE = $(PKG_BASENAME).common.tests.zip
 CPP_TEST_PACKAGE = $(PKG_BASENAME).cppunittest.tests.zip
 XPC_TEST_PACKAGE = $(PKG_BASENAME).xpcshell.tests.zip
 MOCHITEST_PACKAGE = $(PKG_BASENAME).mochitest.tests.zip
 REFTEST_PACKAGE = $(PKG_BASENAME).reftest.tests.zip
 WP_TEST_PACKAGE = $(PKG_BASENAME).web-platform.tests.zip
 TALOS_PACKAGE = $(PKG_BASENAME).talos.tests.zip
+GTEST_PACKAGE = $(PKG_BASENAME).gtest.tests.zip
 
 ifneq (,$(wildcard $(DIST)/bin/application.ini))
 BUILDID = $(shell $(PYTHON) $(MOZILLA_DIR)/config/printconfigsetting.py $(DIST)/bin/application.ini App BuildID)
 else
 BUILDID = $(shell $(PYTHON) $(MOZILLA_DIR)/config/printconfigsetting.py $(DIST)/bin/platform.ini Build BuildID)
 endif
 
 ifndef INCLUDED_RCS_MK
--- a/toolkit/mozapps/installer/upload-files.mk
+++ b/toolkit/mozapps/installer/upload-files.mk
@@ -738,16 +738,17 @@ UPLOAD_FILES= \
   $(call QUOTED_WILDCARD,$(DIST)/$(PKG_PATH)$(MOZHARNESS_PACKAGE)) \
   $(call QUOTED_WILDCARD,$(DIST)/$(PKG_PATH)$(TEST_PACKAGE)) \
   $(call QUOTED_WILDCARD,$(DIST)/$(PKG_PATH)$(CPP_TEST_PACKAGE)) \
   $(call QUOTED_WILDCARD,$(DIST)/$(PKG_PATH)$(XPC_TEST_PACKAGE)) \
   $(call QUOTED_WILDCARD,$(DIST)/$(PKG_PATH)$(MOCHITEST_PACKAGE)) \
   $(call QUOTED_WILDCARD,$(DIST)/$(PKG_PATH)$(TALOS_PACKAGE)) \
   $(call QUOTED_WILDCARD,$(DIST)/$(PKG_PATH)$(REFTEST_PACKAGE)) \
   $(call QUOTED_WILDCARD,$(DIST)/$(PKG_PATH)$(WP_TEST_PACKAGE)) \
+  $(call QUOTED_WILDCARD,$(DIST)/$(PKG_PATH)$(GTEST_PACKAGE)) \
   $(call QUOTED_WILDCARD,$(DIST)/$(PKG_PATH)$(SYMBOL_ARCHIVE_BASENAME).zip) \
   $(call QUOTED_WILDCARD,$(DIST)/$(SDK)) \
   $(call QUOTED_WILDCARD,$(MOZ_SOURCESTAMP_FILE)) \
   $(call QUOTED_WILDCARD,$(MOZ_BUILDINFO_FILE)) \
   $(call QUOTED_WILDCARD,$(MOZ_MOZINFO_FILE)) \
   $(call QUOTED_WILDCARD,$(MOZ_TEST_PACKAGES_FILE)) \
   $(call QUOTED_WILDCARD,$(PKG_JSSHELL)) \
   $(if $(UPLOAD_EXTRA_FILES), $(foreach f, $(UPLOAD_EXTRA_FILES), $(wildcard $(DIST)/$(f))))