Bug 1316729 - Pass command-line args to gtest. r=ted
authorEric Rahm <erahm@mozilla.com>
Wed, 16 Nov 2016 13:04:11 -0800
changeset 322823 8df58dfdea13c9c79975abb4e0c6514b1b4da5f6
parent 322822 6626c876b0875af1b18718d322712bb4b56f39b7
child 322824 ffc63be3557c3a9531591b28adff6feb0e88e3e3
child 322905 c27117f67fa3ff30bbd34bcd6c7536c0d10bd4ad
push id83984
push usererahm@mozilla.com
push dateWed, 16 Nov 2016 21:04:18 +0000
treeherdermozilla-inbound@8df58dfdea13 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs1316729
milestone53.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 1316729 - Pass command-line args to gtest. r=ted MozReview-Commit-ID: 8Xs52E9NnCq
testing/gtest/mozilla/GTestRunner.cpp
testing/gtest/mozilla/GTestRunner.h
toolkit/xre/nsAppRunner.cpp
--- a/testing/gtest/mozilla/GTestRunner.cpp
+++ b/testing/gtest/mozilla/GTestRunner.cpp
@@ -71,20 +71,19 @@ static void ReplaceGTestLogger()
   // Code is based on: http://googletest.googlecode.com/svn/trunk/samples/sample9_unittest.cc
   UnitTest& unitTest = *UnitTest::GetInstance();
   TestEventListeners& listeners = unitTest.listeners();
   delete listeners.Release(listeners.default_result_printer());
 
   listeners.Append(new MozillaPrinter);
 }
 
-int RunGTestFunc()
+int RunGTestFunc(int* argc, char** argv)
 {
-  int c = 0;
-  InitGoogleTest(&c, static_cast<char**>(nullptr));
+  InitGoogleTest(argc, argv);
 
   if (getenv("MOZ_TBPL_PARSER")) {
     ReplaceGTestLogger();
   }
 
   PR_SetEnv("XPCOM_DEBUG_BREAK=stack-and-abort");
 
   ScopedXPCOM xpcom("GTest");
--- a/testing/gtest/mozilla/GTestRunner.h
+++ b/testing/gtest/mozilla/GTestRunner.h
@@ -1,10 +1,10 @@
 /* -*- 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/. */
 
 namespace mozilla {
 
-extern int (*RunGTest)();
+extern int (*RunGTest)(int*, char**);
 
 } // namespace mozilla
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -272,17 +272,17 @@ LibFuzzerRunner* libFuzzerRunner = 0;
 } // namespace mozilla
 
 extern "C" MOZ_EXPORT void XRE_LibFuzzerSetMain(int argc, char** argv, LibFuzzerMain main) {
   mozilla::libFuzzerRunner->setParams(argc, argv, main);
 }
 #endif
 
 namespace mozilla {
-int (*RunGTest)() = 0;
+int (*RunGTest)(int*, char**) = 0;
 } // namespace mozilla
 
 using namespace mozilla;
 using mozilla::Unused;
 using mozilla::scache::StartupCache;
 using mozilla::dom::ContentParent;
 using mozilla::dom::ContentChild;
 
@@ -3735,17 +3735,17 @@ XREMain::XRE_mainStartup(bool* aExitFlag
   if (PR_GetEnv("MOZ_RUN_GTEST")) {
     int result;
 #ifdef XP_WIN
     UseParentConsole();
 #endif
     // RunGTest will only be set if we're in xul-unit
     if (mozilla::RunGTest) {
       gIsGtest = true;
-      result = mozilla::RunGTest();
+      result = mozilla::RunGTest(&gArgc, gArgv);
       gIsGtest = false;
     } else {
       result = 1;
       printf("TEST-UNEXPECTED-FAIL | gtest | Not compiled with enable-tests\n");
     }
     *aExitFlag = true;
     return result;
   }