Bug 986160 - Add MozGtestFriend.h to deal with gtest in non test builds. r=glandium
authorBenoit Girard <b56girard@gmail.com>
Mon, 07 Apr 2014 15:23:03 -0400
changeset 201602 ba1a2edc9f462033c2e6a631066f701dc00a812f
parent 201601 71110537b22f9f0a97f392e525ba53128aed38f3
child 201603 6e6296b804c29f90e7f2e1b55bbe4c89b4d606b8
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs986160
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 986160 - Add MozGtestFriend.h to deal with gtest in non test builds. r=glandium
configure.in
dom/ipc/moz.build
netwerk/ipc/NeckoCommon.h
testing/gtest/MozGtestFriend.h
testing/gtest/moz.build
testing/marionette/moz.build
toolkit/toolkit.mozbuild
--- a/configure.in
+++ b/configure.in
@@ -6347,16 +6347,17 @@ dnl build the tests by default
 dnl ========================================================
 MOZ_ARG_DISABLE_BOOL(tests,
 [  --disable-tests         Do not build test libraries & programs],
     ENABLE_TESTS=,
     ENABLE_TESTS=1 )
 
 if test -n "$ENABLE_TESTS"; then
     GTEST_HAS_RTTI=0
+    AC_DEFINE(ENABLE_TESTS)
     AC_DEFINE_UNQUOTED(GTEST_HAS_RTTI, 0)
     AC_SUBST(GTEST_HAS_RTTI)
     if test -n "$_WIN32_MSVC"; then
           AC_DEFINE_UNQUOTED(_VARIADIC_MAX, 10)
     fi
     if test "${OS_TARGET}" = "Android"; then
         AC_DEFINE(GTEST_OS_LINUX_ANDROID)
         AC_DEFINE(GTEST_USE_OWN_TR1_TUPLE)
--- a/dom/ipc/moz.build
+++ b/dom/ipc/moz.build
@@ -125,15 +125,14 @@ DEFINES['BIN_SUFFIX'] = '"%s"' % CONFIG[
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gonk', 'qt'):
     DEFINES['MOZ_ENABLE_FREETYPE'] = True
 
 for var in ('MOZ_PERMISSIONS', 'MOZ_CHILD_PERMISSIONS'):
     if CONFIG[var]:
         DEFINES[var] = True
 
 if CONFIG['ENABLE_TESTS']:
-    DEFINES['ENABLE_TESTS'] = 1
     LOCAL_INCLUDES += [
       'ipc/glue',
     ]
 
 JAR_MANIFESTS += ['jar.mn']
 
--- a/netwerk/ipc/NeckoCommon.h
+++ b/netwerk/ipc/NeckoCommon.h
@@ -12,17 +12,17 @@
 #include "prenv.h"
 #include "nsPrintfCString.h"
 #include "mozilla/Preferences.h"
 
 namespace mozilla { namespace dom {
 class TabChild;
 }}
 
-#if defined(DEBUG) || defined(ENABLE_TESTS)
+#if defined(DEBUG)
 # define NECKO_ERRORS_ARE_FATAL_DEFAULT true
 #else
 # define NECKO_ERRORS_ARE_FATAL_DEFAULT false
 #endif 
 
 // TODO: Eventually remove NECKO_MAYBE_ABORT and DROP_DEAD (bug 575494).
 // Still useful for catching listener interfaces we don't yet support across
 // processes, etc.
new file mode 100644
--- /dev/null
+++ b/testing/gtest/MozGtestFriend.h
@@ -0,0 +1,15 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+#ifndef GTEST_MOZGTESTFRIEND_H
+#define GTEST_MOZGTESTFRIEND_H
+
+#ifdef ENABLE_TESTS
+#include "gtest_prod.h"
+#else
+#define FRIEND_TEST(a, b)
+#endif
+
+#endif // GTEST_MOZGTESTFRIEND_H
--- a/testing/gtest/moz.build
+++ b/testing/gtest/moz.build
@@ -1,75 +1,80 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # 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/.
 
 EXPORTS.gtest += [
-    'gtest/include/gtest/gtest-death-test.h',
-    'gtest/include/gtest/gtest-message.h',
-    'gtest/include/gtest/gtest-param-test.h',
-    'gtest/include/gtest/gtest-printers.h',
-    'gtest/include/gtest/gtest-spi.h',
-    'gtest/include/gtest/gtest-test-part.h',
-    'gtest/include/gtest/gtest-typed-test.h',
-    'gtest/include/gtest/gtest.h',
-    'gtest/include/gtest/gtest_pred_impl.h',
-    'gtest/include/gtest/gtest_prod.h',
-]
-
-# GTest internal are exposed in gtest.h. See comment in gtest.h
-EXPORTS.gtest.internal += [
-    'gtest/include/gtest/internal/gtest-death-test-internal.h',
-    'gtest/include/gtest/internal/gtest-filepath.h',
-    'gtest/include/gtest/internal/gtest-internal.h',
-    'gtest/include/gtest/internal/gtest-linked_ptr.h',
-    'gtest/include/gtest/internal/gtest-param-util-generated.h',
-    'gtest/include/gtest/internal/gtest-param-util.h',
-    'gtest/include/gtest/internal/gtest-port.h',
-    'gtest/include/gtest/internal/gtest-string.h',
-    'gtest/include/gtest/internal/gtest-tuple.h',
-    'gtest/include/gtest/internal/gtest-type-util.h',
+    'MozGtestFriend.h',
 ]
 
-EXPORTS.gmock += [
-    'gmock/include/gmock/gmock-actions.h',
-    'gmock/include/gmock/gmock-cardinalities.h',
-    'gmock/include/gmock/gmock-generated-actions.h',
-    'gmock/include/gmock/gmock-generated-function-mockers.h',
-    'gmock/include/gmock/gmock-generated-matchers.h',
-    'gmock/include/gmock/gmock-generated-nice-strict.h',
-    'gmock/include/gmock/gmock-matchers.h',
-    'gmock/include/gmock/gmock-more-actions.h',
-    'gmock/include/gmock/gmock-spec-builders.h',
-    'gmock/include/gmock/gmock.h',
-]
+if CONFIG['ENABLE_TESTS']:
+    EXPORTS.gtest += [
+        'gtest/include/gtest/gtest-death-test.h',
+        'gtest/include/gtest/gtest-message.h',
+        'gtest/include/gtest/gtest-param-test.h',
+        'gtest/include/gtest/gtest-printers.h',
+        'gtest/include/gtest/gtest-spi.h',
+        'gtest/include/gtest/gtest-test-part.h',
+        'gtest/include/gtest/gtest-typed-test.h',
+        'gtest/include/gtest/gtest.h',
+        'gtest/include/gtest/gtest_pred_impl.h',
+        'gtest/include/gtest/gtest_prod.h',
+    ]
 
-# gmock also includes internal interfaces in it's public header
-EXPORTS.gmock.internal += [
-    'gmock/include/gmock/internal/gmock-generated-internal-utils.h',
-    'gmock/include/gmock/internal/gmock-internal-utils.h',
-    'gmock/include/gmock/internal/gmock-port.h',
-]
+    # GTest internal are exposed in gtest.h. See comment in gtest.h
+    EXPORTS.gtest.internal += [
+        'gtest/include/gtest/internal/gtest-death-test-internal.h',
+        'gtest/include/gtest/internal/gtest-filepath.h',
+        'gtest/include/gtest/internal/gtest-internal.h',
+        'gtest/include/gtest/internal/gtest-linked_ptr.h',
+        'gtest/include/gtest/internal/gtest-param-util-generated.h',
+        'gtest/include/gtest/internal/gtest-param-util.h',
+        'gtest/include/gtest/internal/gtest-port.h',
+        'gtest/include/gtest/internal/gtest-string.h',
+        'gtest/include/gtest/internal/gtest-tuple.h',
+        'gtest/include/gtest/internal/gtest-type-util.h',
+    ]
 
-SOURCES += [
-    'gmock/src/gmock-all.cc',
-    'gtest/src/gtest-all.cc',
-    'mozilla/GTestRunner.cpp',
-]
+    EXPORTS.gmock += [
+        'gmock/include/gmock/gmock-actions.h',
+        'gmock/include/gmock/gmock-cardinalities.h',
+        'gmock/include/gmock/gmock-generated-actions.h',
+        'gmock/include/gmock/gmock-generated-function-mockers.h',
+        'gmock/include/gmock/gmock-generated-matchers.h',
+        'gmock/include/gmock/gmock-generated-nice-strict.h',
+        'gmock/include/gmock/gmock-matchers.h',
+        'gmock/include/gmock/gmock-more-actions.h',
+        'gmock/include/gmock/gmock-spec-builders.h',
+        'gmock/include/gmock/gmock.h',
+    ]
 
-LIBRARY_NAME = 'gtest'
+    # gmock also includes internal interfaces in it's public header
+    EXPORTS.gmock.internal += [
+        'gmock/include/gmock/internal/gmock-generated-internal-utils.h',
+        'gmock/include/gmock/internal/gmock-internal-utils.h',
+        'gmock/include/gmock/internal/gmock-port.h',
+    ]
 
-SOURCES += [
-    'mozilla/SanityTest.cpp',
-]
+    SOURCES += [
+        'gmock/src/gmock-all.cc',
+        'gtest/src/gtest-all.cc',
+        'mozilla/GTestRunner.cpp',
+    ]
 
-EXPORT_LIBRARY = True
+    LIBRARY_NAME = 'gtest'
 
-LOCAL_INCLUDES += [
-    'gmock',
-    'gmock/include',
-    'gtest',
-    'gtest/include',
-]
+    SOURCES += [
+        'mozilla/SanityTest.cpp',
+    ]
+
+    EXPORT_LIBRARY = True
 
-FINAL_LIBRARY = 'xul-gtest'
+    LOCAL_INCLUDES += [
+        'gmock',
+        'gmock/include',
+        'gtest',
+        'gtest/include',
+    ]
+
+    FINAL_LIBRARY = 'xul-gtest'
--- a/testing/marionette/moz.build
+++ b/testing/marionette/moz.build
@@ -1,12 +1,9 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # 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/.
 
 DIRS += ['components', 'atoms']
 
-if CONFIG['ENABLE_TESTS']:
-    DEFINES['ENABLE_TESTS'] = True
-
-JAR_MANIFESTS += ['jar.mn']
\ No newline at end of file
+JAR_MANIFESTS += ['jar.mn']
--- a/toolkit/toolkit.mozbuild
+++ b/toolkit/toolkit.mozbuild
@@ -85,18 +85,17 @@ if CONFIG['MOZ_OMX_PLUGIN']:
         'media/omx-plugin/lib/hc/libstagefright',
         'media/omx-plugin/hc',
         'media/omx-plugin/kk',
     ])
 
 if CONFIG['ENABLE_TESTS']:
     add_tier_dir('platform', 'testing/specialpowers')
 
-if CONFIG['ENABLE_TESTS']:
-    add_tier_dir('platform', 'testing/gtest')
+add_tier_dir('platform', 'testing/gtest')
 
 add_tier_dir('platform', [
     'uriloader',
     'caps',
     'parser',
     'gfx',
     'image',
     'dom',