diff --git a/config/config.mk b/config/config.mk index 5b36ca924a0..1b8fa081743 100644 --- a/config/config.mk +++ b/config/config.mk @@ -747,8 +747,8 @@ CREATE_PRECOMPLETE_CMD = $(PYTHON) $(call core_abspath,$(topsrcdir)/config/creat # MDDEPDIR is the subdirectory where dependency files are stored MDDEPDIR := .deps -EXPAND_LIBS_EXEC = $(PYTHON) $(topsrcdir)/config/expandlibs_exec.py $(if $@,--depend $(MDDEPDIR)/$(@F).pp --target $@) -EXPAND_LIBS_GEN = $(PYTHON) $(topsrcdir)/config/expandlibs_gen.py $(if $@,--depend $(MDDEPDIR)/$(@F).pp) +EXPAND_LIBS_EXEC = $(PYTHON) $(topsrcdir)/config/expandlibs_exec.py $(if $@,--depend $(MDDEPDIR)/$(dir $@)/$(@F).pp --target $@) +EXPAND_LIBS_GEN = $(PYTHON) $(topsrcdir)/config/expandlibs_gen.py $(if $@,--depend $(MDDEPDIR)/$(dir $@)/$(@F).pp) EXPAND_AR = $(EXPAND_LIBS_EXEC) --extract -- $(AR) EXPAND_CC = $(EXPAND_LIBS_EXEC) --uselist -- $(CC) EXPAND_CCC = $(EXPAND_LIBS_EXEC) --uselist -- $(CCC) diff --git a/configure.in b/configure.in index 8d999420e04..b88ff5354dc 100644 --- a/configure.in +++ b/configure.in @@ -1330,8 +1330,8 @@ if test "$GNU_CC"; then CFLAGS="$CFLAGS -std=gnu99 -fgnu89-inline" # FIXME: Let us build with strict aliasing. bug 414641. CFLAGS="$CFLAGS -fno-strict-aliasing" - MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@' - MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@' + MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(notdir $@) -o $@' + MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(notdir $@) -o $@' DSO_LDOPTS='-shared' if test "$GCC_USE_GNU_LD"; then # Some tools like ASan use a runtime library that is only @@ -1441,8 +1441,8 @@ elif test "$SOLARIS_SUNPRO_CC"; then fi _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT' else - MKSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@' - MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@' + MKSHLIB='$(LD) $(DSO_LDOPTS) -h $(notdir $@) -o $@' + MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $(notdir $@) -o $@' DSO_LDOPTS='-shared' if test "$GNU_LD"; then @@ -2301,8 +2301,8 @@ ia64*-hpux*) if test "$LIBRUNPATH"; then DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS" fi - MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@' - MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@' + MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(notdir $@) -o $@' + MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(notdir $@)) -o $@' ;; *-openbsd*) @@ -2408,8 +2408,8 @@ ia64*-hpux*) [LDFLAGS=$_SAVE_LDFLAGS]) fi MOZ_OPTIMIZE_FLAGS="-xO4" - MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@' - MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@' + MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $(notdir $@) -o $@' + MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $(notdir $@) -o $@' MKSHLIB_FORCE_ALL='-z allextract' MKSHLIB_UNFORCE_ALL='-z defaultextract' DSO_LDOPTS='-G' @@ -6417,25 +6417,15 @@ MOZ_ARG_DISABLE_BOOL(tests, ENABLE_TESTS=, ENABLE_TESTS=1 ) -# Currently GTest is linked into libxul. This means it must be off by default. -# Follow up will be to generate libxul.so and libxul-test.so to let GTest -# be compiled along with ENABLE_TESTS -MOZ_ARG_ENABLE_BOOL(gtest, -[ --enable-gtest - Enable GTest libxul unit test.], - MOZ_ENABLE_GTEST=1, - MOZ_ENABLE_GTEST= ) - -if test -n "$MOZ_ENABLE_GTEST"; then - if test "${OS_TARGET}" = "WINNT" -o "${OS_TARGET}" = "Darwin" -o "${OS_TARGET}" = "Linux" -o "${OS_TARGET}" = "Android"; then - MOZ_ENABLE_GTEST=1 - GTEST_HAS_RTTI=0 - AC_DEFINE(MOZ_ENABLE_GTEST) - AC_DEFINE_UNQUOTED(GTEST_HAS_RTTI, 0) - AC_SUBST(MOZ_ENABLE_GTEST) - AC_SUBST(GTEST_HAS_RTTI) - else - AC_MSG_ERROR([Cannot build with --enable-gtest on this platform.]) +if test -n "$ENABLE_TESTS"; then + MOZ_ENABLE_GTEST=1 + GTEST_HAS_RTTI=0 + AC_DEFINE(MOZ_ENABLE_GTEST) + AC_DEFINE_UNQUOTED(GTEST_HAS_RTTI, 0) + AC_SUBST(MOZ_ENABLE_GTEST) + 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) diff --git a/gfx/2d/Makefile.in b/gfx/2d/Makefile.in index c87b6fb7c3f..c86a089de47 100644 --- a/gfx/2d/Makefile.in +++ b/gfx/2d/Makefile.in @@ -15,14 +15,6 @@ MSVC_ENABLE_PGO := 1 LIBXUL_LIBRARY = 1 EXPORT_LIBRARY = 1 -GTEST_CPPSRCS = \ - GTestMain.cpp \ - TestBase.cpp \ - TestPoint.cpp \ - TestScaling.cpp \ - TestCairo.cpp \ - $(NULL) - ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) CMMSRCS = \ QuartzSupport.mm \ diff --git a/gfx/layers/Makefile.in b/gfx/layers/Makefile.in index e0f5fc1bf08..4b4d38541ca 100644 --- a/gfx/layers/Makefile.in +++ b/gfx/layers/Makefile.in @@ -30,10 +30,6 @@ ifdef MOZ_DEBUG DEFINES += -DD3D_DEBUG_INFO endif -GTEST_CPPSRCS = \ - TestTiledLayerBuffer.cpp \ - $(NULL) - ifdef MOZ_ENABLE_D3D10_LAYER DEFINES += -DMOZ_ENABLE_D3D10_LAYER endif diff --git a/gfx/moz.build b/gfx/moz.build index 7a6b638d3c9..3e8016f7d4d 100644 --- a/gfx/moz.build +++ b/gfx/moz.build @@ -25,6 +25,9 @@ DIRS += [ if CONFIG['MOZ_ENABLE_SKIA']: DIRS += ['skia'] +if CONFIG['ENABLE_TESTS']: + DIRS += ['tests/gtest'] + TEST_TOOL_DIRS += ['tests'] MODULE = 'gfx' diff --git a/gfx/tests/gtest/Makefile.in b/gfx/tests/gtest/Makefile.in new file mode 100644 index 00000000000..605828bf79d --- /dev/null +++ b/gfx/tests/gtest/Makefile.in @@ -0,0 +1,43 @@ +# +# 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/. + +DEPTH = @DEPTH@ +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ $(srcdir)/$(DEPTH)/gfx/2d/unittest +relativesrcdir = @relativesrcdir@ + +include $(DEPTH)/config/autoconf.mk + +# Create a GTest library +MODULE_NAME = gfxtest +LIBRARY_NAME = gfxtest +LIBXUL_LIBRARY = 1 +IS_COMPONENT = 1 +EXPORT_LIBRARY = 1 + +LOCAL_INCLUDES = \ + -I$(topsrcdir)/gfx/layers \ + -I$(topsrcdir)/gfx/2d \ + -I$(topsrcdir)/gfx/2d/unittest \ + $(NULL) + +GTEST_CPPSRCS = \ + TestTiledLayerBuffer.cpp \ + $(NULL) + +# Because of gkmedia on windows we wont find these +# symbols in xul.dll. +ifneq ($(MOZ_WIDGET_TOOLKIT),windows) +GTEST_CPPSRCS += \ + TestMoz2D.cpp \ + TestBase.cpp \ + TestPoint.cpp \ + TestScaling.cpp \ + $(NULL) +endif + +include $(topsrcdir)/config/rules.mk + diff --git a/gfx/2d/unittest/GTestMain.cpp b/gfx/tests/gtest/TestMoz2D.cpp similarity index 100% rename from gfx/2d/unittest/GTestMain.cpp rename to gfx/tests/gtest/TestMoz2D.cpp diff --git a/gfx/layers/TestTiledLayerBuffer.cpp b/gfx/tests/gtest/TestTiledLayerBuffer.cpp similarity index 100% rename from gfx/layers/TestTiledLayerBuffer.cpp rename to gfx/tests/gtest/TestTiledLayerBuffer.cpp diff --git a/gfx/tests/gtest/moz.build b/gfx/tests/gtest/moz.build new file mode 100644 index 00000000000..8e5d082367e --- /dev/null +++ b/gfx/tests/gtest/moz.build @@ -0,0 +1,8 @@ +# -*- 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/. + +MODULE = 'gfxtest' + diff --git a/js/src/config/config.mk b/js/src/config/config.mk index 5b36ca924a0..1b8fa081743 100644 --- a/js/src/config/config.mk +++ b/js/src/config/config.mk @@ -747,8 +747,8 @@ CREATE_PRECOMPLETE_CMD = $(PYTHON) $(call core_abspath,$(topsrcdir)/config/creat # MDDEPDIR is the subdirectory where dependency files are stored MDDEPDIR := .deps -EXPAND_LIBS_EXEC = $(PYTHON) $(topsrcdir)/config/expandlibs_exec.py $(if $@,--depend $(MDDEPDIR)/$(@F).pp --target $@) -EXPAND_LIBS_GEN = $(PYTHON) $(topsrcdir)/config/expandlibs_gen.py $(if $@,--depend $(MDDEPDIR)/$(@F).pp) +EXPAND_LIBS_EXEC = $(PYTHON) $(topsrcdir)/config/expandlibs_exec.py $(if $@,--depend $(MDDEPDIR)/$(dir $@)/$(@F).pp --target $@) +EXPAND_LIBS_GEN = $(PYTHON) $(topsrcdir)/config/expandlibs_gen.py $(if $@,--depend $(MDDEPDIR)/$(dir $@)/$(@F).pp) EXPAND_AR = $(EXPAND_LIBS_EXEC) --extract -- $(AR) EXPAND_CC = $(EXPAND_LIBS_EXEC) --uselist -- $(CC) EXPAND_CCC = $(EXPAND_LIBS_EXEC) --uselist -- $(CCC) diff --git a/js/src/configure.in b/js/src/configure.in index e7fe3a32442..fe18b005eaa 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -1151,8 +1151,8 @@ if test "$GNU_CC"; then # Per bug 719659 comment 2, some of the headers on ancient build machines # may require gnu89 inline semantics. But otherwise, we use C99. CFLAGS="$CFLAGS -std=gnu99 -fgnu89-inline" - MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@' - MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@' + MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(notdir $@) -o $@' + MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(notdir $@) -o $@' DSO_LDOPTS='-shared' if test "$GCC_USE_GNU_LD"; then # Some tools like ASan use a runtime library that is only @@ -1225,8 +1225,8 @@ elif test "$SOLARIS_SUNPRO_CC"; then fi _DEFINES_CFLAGS='$(ACDEFINES) -D_JS_CONFDEFS_H_ -DMOZILLA_CLIENT' else - MKSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@' - MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@' + MKSHLIB='$(LD) $(DSO_LDOPTS) -h $(notdir $@) -o $@' + MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $(notdir $@) -o $@' DSO_LDOPTS='-shared' if test "$GNU_LD"; then @@ -1845,8 +1845,8 @@ ia64*-hpux*) if test "$LIBRUNPATH"; then DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS" fi - MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@' - MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@' + MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(notdir $@) -o $@' + MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(notdir $@) -o $@' ;; *-openbsd*) @@ -1949,8 +1949,8 @@ ia64*-hpux*) [LDFLAGS=$_SAVE_LDFLAGS]) fi MOZ_OPTIMIZE_FLAGS="-xO4" - MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@' - MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@' + MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $(notdir $@) -o $@' + MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $(notdir $@) -o $@' MKSHLIB_FORCE_ALL='-z allextract' MKSHLIB_UNFORCE_ALL='-z defaultextract' DSO_LDOPTS='-G' diff --git a/python/mozbuild/mozbuild/mach_commands.py b/python/mozbuild/mozbuild/mach_commands.py index 39c1753eb21..bfbf91bf70a 100644 --- a/python/mozbuild/mozbuild/mach_commands.py +++ b/python/mozbuild/mozbuild/mach_commands.py @@ -464,6 +464,10 @@ class GTestCommands(MachCommandBase): @CommandArgument('--shuffle', '-s', action='store_true', help='Randomize the execution order of tests.') def gtest(self, shuffle, jobs, gtest_filter, tbpl_parser): + + # We lazy build gtest because it's slow to link + self._run_make(directory="testing/gtest", target='gtest', ensure_exit_code=True) + app_path = self.get_binary_path('app') # Use GTest environment variable to control test execution @@ -471,6 +475,8 @@ class GTestCommands(MachCommandBase): # https://code.google.com/p/googletest/wiki/AdvancedGuide#Running_Test_Programs:_Advanced_Options gtest_env = {b'GTEST_FILTER': gtest_filter} + gtest_env[b"MOZ_RUN_GTEST"] = b"True" + if shuffle: gtest_env[b"GTEST_SHUFFLE"] = b"True" diff --git a/testing/gtest/Makefile.in b/testing/gtest/Makefile.in index c9a94e65cbd..e332f819606 100644 --- a/testing/gtest/Makefile.in +++ b/testing/gtest/Makefile.in @@ -36,3 +36,15 @@ LOCAL_INCLUDES += \ include $(topsrcdir)/config/rules.mk +ifeq (browser,$(MOZ_BUILD_APP)) +# Disable because of metro linking error: +# LNK1181: cannot open input file 'runtimeobject.lib' +ifndef MOZ_METRO +check gtest:: + $(MAKE) -C $(DEPTH)/toolkit/library gtestxul +ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) + $(MAKE) -C $(DEPTH)/browser/app repackage +endif +endif +endif + diff --git a/testing/gtest/mozilla/GTestRunner.cpp b/testing/gtest/mozilla/GTestRunner.cpp index 20ab0847e03..863c4242058 100644 --- a/testing/gtest/mozilla/GTestRunner.cpp +++ b/testing/gtest/mozilla/GTestRunner.cpp @@ -3,9 +3,11 @@ * * 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/. */ +#include "GTestRunner.h" #include "gtest/gtest.h" #include "mozilla/Attributes.h" #include "mozilla/NullPtr.h" +#include "prenv.h" using ::testing::EmptyTestEventListener; using ::testing::InitGoogleTest; @@ -65,7 +67,7 @@ static void ReplaceGTestLogger() listeners.Append(new MozillaPrinter); } -int RunGTest() +int RunGTestFunc() { int c = 0; InitGoogleTest(&c, static_cast(nullptr)); @@ -74,9 +76,20 @@ int RunGTest() ReplaceGTestLogger(); } - setenv("XPCOM_DEBUG_BREAK", "stack-and-abort", false); + PR_SetEnv("XPCOM_DEBUG_BREAK=stack-and-abort"); return RUN_ALL_TESTS(); } +// We use a static var 'RunGTest' defined in nsAppRunner.cpp. +// RunGTest is initialized to NULL but if GTest (this file) +// is linked in then RunGTest will be set here indicating +// GTest is supported. +class _InitRunGTest { +public: + _InitRunGTest() { + RunGTest = RunGTestFunc; + } +} InitRunGTest; + } diff --git a/testing/gtest/mozilla/GTestRunner.h b/testing/gtest/mozilla/GTestRunner.h index 077af6514d9..14bf9881202 100644 --- a/testing/gtest/mozilla/GTestRunner.h +++ b/testing/gtest/mozilla/GTestRunner.h @@ -5,6 +5,6 @@ namespace mozilla { -int RunGTest(); +extern int (*RunGTest)(); } diff --git a/toolkit/library/Makefile.in b/toolkit/library/Makefile.in index d652dd06ad0..8149b4bd6e3 100644 --- a/toolkit/library/Makefile.in +++ b/toolkit/library/Makefile.in @@ -300,10 +300,6 @@ endif STATIC_LIBS += thebes gl ycbcr -ifdef MOZ_ENABLE_GTEST -COMPONENT_LIBS += gtest xpcom_glue_gtest -endif - ifdef MOZ_ENABLE_PROFILER_SPS COMPONENT_LIBS += profiler endif @@ -652,6 +648,15 @@ LIBXUL_AUTOLOAD = libxul.so-gdb.py.in LIBXUL_AUTOLOAD_FLAGS := -Dtopsrcdir=$(abspath $(topsrcdir)) endif +ifdef MAKE_FRAMEWORK +EFFECTIVE_LIB_PREFIX= +else +EFFECTIVE_LIB_PREFIX=$(DLL_PREFIX) +endif + +GTEST_LIB = $(EFFECTIVE_LIB_PREFIX)gtest/$(EFFECTIVE_LIB_PREFIX)$(LIBRARY_NAME).$(DLL_SUFFIX) +EXTRA_MDDEPEND_FILES = $(GTEST_LIB).pp + include $(topsrcdir)/config/rules.mk export:: $(RDF_UTIL_SRC_CPPSRCS) $(INTL_UNICHARUTIL_UTIL_CPPSRCS) @@ -689,7 +694,37 @@ ifeq (WINNT_1,$(OS_TARGET)_$(MOZ_PROFILE_USE)) LD := $(PYTHON) $(topsrcdir)/build/link.py $(CURDIR)/linker-vsize $(LD) endif +ifndef LINK_GTEST libs:: $(FINAL_TARGET)/dependentlibs.list +else +libs:: +endif + +.PHONY: gtestxul + +$(FINAL_TARGET)/dependentlibs.list.gtest: $(FINAL_TARGET)/dependentlibs.list + sed -e "s|$(SHARED_LIBRARY)|gtest/$(SHARED_LIBRARY)|" $< > $@ + +# Remove this target when actually linking gtest to prevent redefining +# the implicit rules.mk target +ifndef LINK_GTEST + +gtestxul: $(GTEST_LIB) + +$(GTEST_LIB): $(FINAL_TARGET)/dependentlibs.list.gtest + $(MKDIR) -p $(EFFECTIVE_LIB_PREFIX)gtest + $(MAKE) libs SHARED_LIBRARY_NAME=gtest/$(EFFECTIVE_LIB_PREFIX)$(LIBRARY_NAME) FINAL_TARGET=$(FINAL_TARGET)/gtest SDK_LIBRARY= IMPORT_LIB_DEST=$(IMPORT_LIB_DEST)/gtest LINK_GTEST=true +endif + +ifdef LINK_GTEST + +COMPONENT_LIBS += \ + gtest \ + gfxtest \ + $(NULL) +endif $(FINAL_TARGET)/dependentlibs.list: dependentlibs.py $(SHARED_LIBRARY) $(wildcard $(if $(wildcard $(FINAL_TARGET)/dependentlibs.list),$(addprefix $(FINAL_TARGET)/,$(shell cat $(FINAL_TARGET)/dependentlibs.list)))) $(PYTHON) $< $(SHARED_LIBRARY) -L $(FINAL_TARGET) $(if $(TOOLCHAIN_PREFIX),$(addprefix -p ,$(TOOLCHAIN_PREFIX))) > $@ + + diff --git a/toolkit/library/winvccorlib/Makefile.in b/toolkit/library/winvccorlib/Makefile.in index f948ad58245..cd48afd9b06 100644 --- a/toolkit/library/winvccorlib/Makefile.in +++ b/toolkit/library/winvccorlib/Makefile.in @@ -7,11 +7,17 @@ topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ +# When we're linking GTest we recurse into this directory but don't need +# to generate this library +ifndef LINK_GTEST + LIBRARY_NAME = dummyvccorlib include $(DEPTH)/config/autoconf.mk FORCE_SHARED_LIB=1 +endif + include $(topsrcdir)/config/rules.mk diff --git a/toolkit/toolkit.mozbuild b/toolkit/toolkit.mozbuild index 1480e7336ea..8e1b0dd73b6 100644 --- a/toolkit/toolkit.mozbuild +++ b/toolkit/toolkit.mozbuild @@ -128,9 +128,8 @@ add_tier_dir('platform', 'media/kiss_fft') if CONFIG['ENABLE_TESTS']: add_tier_dir('platform', 'testing/specialpowers') -if CONFIG['MOZ_ENABLE_GTEST']: +if CONFIG['ENABLE_TESTS']: add_tier_dir('platform', 'testing/gtest') - add_tier_dir('platform', 'xpcom/glue/tests/gtest') add_tier_dir('platform', [ 'uriloader', diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 49acfdbac8b..cc3f65e7302 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -196,7 +196,7 @@ using mozilla::scache::StartupCache; #endif #include "base/command_line.h" -#ifdef MOZ_ENABLE_GTEST +#ifdef MOZ_ENABLE_TESTS #include "GTestRunner.h" #endif @@ -242,6 +242,10 @@ static char **gQtOnlyArgv; #endif #include "BinaryPath.h" +namespace mozilla { +int (*RunGTest)() = 0; +} + using mozilla::dom::ContentParent; using mozilla::dom::ContentChild; @@ -3177,14 +3181,15 @@ XREMain::XRE_mainInit(bool* aExitFlag) return 0; } - ar = CheckArg("unittest", true); - if (ar == ARG_FOUND) { -#if MOZ_ENABLE_GTEST - int result = mozilla::RunGTest(); -#else - int result = 1; - printf("TEST-UNEXPECTED-FAIL | Not compiled with GTest enabled\n"); -#endif + if (PR_GetEnv("MOZ_RUN_GTEST")) { + int result; + // RunGTest will only be set if we're in xul-unit + if (mozilla::RunGTest) { + result = mozilla::RunGTest(); + } else { + result = 1; + printf("TEST-UNEXPECTED-FAIL | gtest | Not compiled with enable-tests\n"); + } *aExitFlag = true; return result; } diff --git a/xpcom/glue/standalone/nsXPCOMGlue.cpp b/xpcom/glue/standalone/nsXPCOMGlue.cpp index 087239271a1..578c70682a1 100644 --- a/xpcom/glue/standalone/nsXPCOMGlue.cpp +++ b/xpcom/glue/standalone/nsXPCOMGlue.cpp @@ -416,6 +416,10 @@ XPCOMGlueLoad(const char *xpcomFile) cursor = xpcomDir; } + if (getenv("MOZ_RUN_GTEST")) { + strcat(xpcomDir, ".gtest"); + } + ScopedCloseFile flist; flist = TS_tfopen(xpcomDir, READ_TEXTMODE); if (!flist) {