Unverified Commit a7a7f51d authored by Tanzinul Islam's avatar Tanzinul Islam Committed by GitHub
Browse files

Merge branch 'master' into fix_death_test_child_mingw_wer_issue1116

parents 4ba3803f 6c73adfc
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// This file is AUTOMATICALLY GENERATED on 10/31/2011 by command // This file is AUTOMATICALLY GENERATED on 01/02/2018 by command
// 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND! // 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND!
// Regression test for gtest_pred_impl.h // Regression test for gtest_pred_impl.h
......
...@@ -29,10 +29,10 @@ ...@@ -29,10 +29,10 @@
// //
// Author: wan@google.com (Zhanyong Wan) // Author: wan@google.com (Zhanyong Wan)
// //
// Unit test for include/gtest/gtest_prod.h. // Unit test for gtest/gtest_prod.h.
#include "production.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "test/production.h"
// Tests that private members can be accessed from a TEST declared as // Tests that private members can be accessed from a TEST declared as
// a friend of the class. // a friend of the class.
......
...@@ -34,15 +34,7 @@ ...@@ -34,15 +34,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <iostream> #include <iostream>
#include "gtest/gtest.h" #include "gtest/gtest.h"
// Indicates that this translation unit is part of Google Test's
// implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in
// their code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
namespace testing { namespace testing {
...@@ -75,7 +67,7 @@ namespace { ...@@ -75,7 +67,7 @@ namespace {
// Used for verifying that global environment set-up and tear-down are // Used for verifying that global environment set-up and tear-down are
// inside the gtest_repeat loop. // inside the --gtest_repeat loop.
int g_environment_set_up_count = 0; int g_environment_set_up_count = 0;
int g_environment_tear_down_count = 0; int g_environment_tear_down_count = 0;
...@@ -119,7 +111,6 @@ TEST(BarDeathTest, ThreadSafeAndFast) { ...@@ -119,7 +111,6 @@ TEST(BarDeathTest, ThreadSafeAndFast) {
EXPECT_DEATH_IF_SUPPORTED(::testing::internal::posix::Abort(), ""); EXPECT_DEATH_IF_SUPPORTED(::testing::internal::posix::Abort(), "");
} }
#if GTEST_HAS_PARAM_TEST
int g_param_test_count = 0; int g_param_test_count = 0;
const int kNumberOfParamTests = 10; const int kNumberOfParamTests = 10;
...@@ -135,7 +126,6 @@ TEST_P(MyParamTest, ShouldPass) { ...@@ -135,7 +126,6 @@ TEST_P(MyParamTest, ShouldPass) {
INSTANTIATE_TEST_CASE_P(MyParamSequence, INSTANTIATE_TEST_CASE_P(MyParamSequence,
MyParamTest, MyParamTest,
testing::Range(0, kNumberOfParamTests)); testing::Range(0, kNumberOfParamTests));
#endif // GTEST_HAS_PARAM_TEST
// Resets the count for each test. // Resets the count for each test.
void ResetCounts() { void ResetCounts() {
...@@ -144,9 +134,7 @@ void ResetCounts() { ...@@ -144,9 +134,7 @@ void ResetCounts() {
g_should_fail_count = 0; g_should_fail_count = 0;
g_should_pass_count = 0; g_should_pass_count = 0;
g_death_test_count = 0; g_death_test_count = 0;
#if GTEST_HAS_PARAM_TEST
g_param_test_count = 0; g_param_test_count = 0;
#endif // GTEST_HAS_PARAM_TEST
} }
// Checks that the count for each test is expected. // Checks that the count for each test is expected.
...@@ -156,9 +144,7 @@ void CheckCounts(int expected) { ...@@ -156,9 +144,7 @@ void CheckCounts(int expected) {
GTEST_CHECK_INT_EQ_(expected, g_should_fail_count); GTEST_CHECK_INT_EQ_(expected, g_should_fail_count);
GTEST_CHECK_INT_EQ_(expected, g_should_pass_count); GTEST_CHECK_INT_EQ_(expected, g_should_pass_count);
GTEST_CHECK_INT_EQ_(expected, g_death_test_count); GTEST_CHECK_INT_EQ_(expected, g_death_test_count);
#if GTEST_HAS_PARAM_TEST
GTEST_CHECK_INT_EQ_(expected * kNumberOfParamTests, g_param_test_count); GTEST_CHECK_INT_EQ_(expected * kNumberOfParamTests, g_param_test_count);
#endif // GTEST_HAS_PARAM_TEST
} }
// Tests the behavior of Google Test when --gtest_repeat is not specified. // Tests the behavior of Google Test when --gtest_repeat is not specified.
...@@ -201,9 +187,7 @@ void TestRepeatWithFilterForSuccessfulTests(int repeat) { ...@@ -201,9 +187,7 @@ void TestRepeatWithFilterForSuccessfulTests(int repeat) {
GTEST_CHECK_INT_EQ_(0, g_should_fail_count); GTEST_CHECK_INT_EQ_(0, g_should_fail_count);
GTEST_CHECK_INT_EQ_(repeat, g_should_pass_count); GTEST_CHECK_INT_EQ_(repeat, g_should_pass_count);
GTEST_CHECK_INT_EQ_(repeat, g_death_test_count); GTEST_CHECK_INT_EQ_(repeat, g_death_test_count);
#if GTEST_HAS_PARAM_TEST
GTEST_CHECK_INT_EQ_(repeat * kNumberOfParamTests, g_param_test_count); GTEST_CHECK_INT_EQ_(repeat * kNumberOfParamTests, g_param_test_count);
#endif // GTEST_HAS_PARAM_TEST
} }
// Tests using --gtest_repeat when --gtest_filter specifies a set of // Tests using --gtest_repeat when --gtest_filter specifies a set of
...@@ -219,15 +203,14 @@ void TestRepeatWithFilterForFailedTests(int repeat) { ...@@ -219,15 +203,14 @@ void TestRepeatWithFilterForFailedTests(int repeat) {
GTEST_CHECK_INT_EQ_(repeat, g_should_fail_count); GTEST_CHECK_INT_EQ_(repeat, g_should_fail_count);
GTEST_CHECK_INT_EQ_(0, g_should_pass_count); GTEST_CHECK_INT_EQ_(0, g_should_pass_count);
GTEST_CHECK_INT_EQ_(0, g_death_test_count); GTEST_CHECK_INT_EQ_(0, g_death_test_count);
#if GTEST_HAS_PARAM_TEST
GTEST_CHECK_INT_EQ_(0, g_param_test_count); GTEST_CHECK_INT_EQ_(0, g_param_test_count);
#endif // GTEST_HAS_PARAM_TEST
} }
} // namespace } // namespace
int main(int argc, char **argv) { int main(int argc, char **argv) {
testing::InitGoogleTest(&argc, argv); testing::InitGoogleTest(&argc, argv);
testing::AddGlobalTestEnvironment(new MyEnvironment); testing::AddGlobalTestEnvironment(new MyEnvironment);
TestRepeatUnspecified(); TestRepeatUnspecified();
......
...@@ -34,15 +34,9 @@ ...@@ -34,15 +34,9 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include <iostream>
#include <vector> #include <vector>
// We must define this macro in order to #include
// gtest-internal-inl.h. This is how Google Test prevents a user from
// accidentally depending on its internal implementation.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
#if GTEST_IS_THREADSAFE #if GTEST_IS_THREADSAFE
......
#!/usr/bin/env python
#
# Copyright 2006, Google Inc. # Copyright 2006, Google Inc.
# All rights reserved. # All rights reserved.
# #
...@@ -30,19 +28,24 @@ ...@@ -30,19 +28,24 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Unit test utilities for Google C++ Testing Framework.""" """Unit test utilities for Google C++ Testing Framework."""
# Suppresses the 'Import not at the top of the file' lint complaint.
# pylint: disable-msg=C6204
__author__ = 'wan@google.com (Zhanyong Wan)' __author__ = 'wan@google.com (Zhanyong Wan)'
import atexit
import os import os
import shutil
import sys import sys
IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'
IS_WINDOWS = os.name == 'nt'
IS_CYGWIN = os.name == 'posix' and 'CYGWIN' in os.uname()[0]
import atexit
import shutil
import tempfile import tempfile
import unittest import unittest
_test_module = unittest _test_module = unittest
# Suppresses the 'Import not at the top of the file' lint complaint.
# pylint: disable-msg=C6204
try: try:
import subprocess import subprocess
_SUBPROCESS_MODULE_AVAILABLE = True _SUBPROCESS_MODULE_AVAILABLE = True
...@@ -53,9 +56,6 @@ except: ...@@ -53,9 +56,6 @@ except:
GTEST_OUTPUT_VAR_NAME = 'GTEST_OUTPUT' GTEST_OUTPUT_VAR_NAME = 'GTEST_OUTPUT'
IS_WINDOWS = os.name == 'nt'
IS_CYGWIN = os.name == 'posix' and 'CYGWIN' in os.uname()[0]
# The environment variable for specifying the path to the premature-exit file. # The environment variable for specifying the path to the premature-exit file.
PREMATURE_EXIT_FILE_ENV_VAR = 'TEST_PREMATURE_EXIT_FILE' PREMATURE_EXIT_FILE_ENV_VAR = 'TEST_PREMATURE_EXIT_FILE'
...@@ -145,8 +145,6 @@ atexit.register(_RemoveTempDir) ...@@ -145,8 +145,6 @@ atexit.register(_RemoveTempDir)
def GetTempDir(): def GetTempDir():
"""Returns a directory for temporary files."""
global _temp_dir global _temp_dir
if not _temp_dir: if not _temp_dir:
_temp_dir = tempfile.mkdtemp() _temp_dir = tempfile.mkdtemp()
...@@ -178,7 +176,7 @@ def GetTestExecutablePath(executable_name, build_dir=None): ...@@ -178,7 +176,7 @@ def GetTestExecutablePath(executable_name, build_dir=None):
'Unable to find the test binary "%s". Please make sure to provide\n' 'Unable to find the test binary "%s". Please make sure to provide\n'
'a path to the binary via the --build_dir flag or the BUILD_DIR\n' 'a path to the binary via the --build_dir flag or the BUILD_DIR\n'
'environment variable.' % path) 'environment variable.' % path)
sys.stdout.write(message) print >> sys.stderr, message
sys.exit(1) sys.exit(1)
return path return path
...@@ -229,7 +227,7 @@ class Subprocess: ...@@ -229,7 +227,7 @@ class Subprocess:
combined in a string. combined in a string.
""" """
# The subprocess module is the preferrable way of running programs # The subprocess module is the preferable way of running programs
# since it is available and behaves consistently on all platforms, # since it is available and behaves consistently on all platforms,
# including Windows. But it is only available starting in python 2.4. # including Windows. But it is only available starting in python 2.4.
# In earlier python versions, we revert to the popen2 module, which is # In earlier python versions, we revert to the popen2 module, which is
......
...@@ -70,7 +70,7 @@ def SetEnvVar(env_var, value): ...@@ -70,7 +70,7 @@ def SetEnvVar(env_var, value):
def Run(command): def Run(command):
"""Runs a command; returns True/False if its exit code is/isn't 0.""" """Runs a command; returns True/False if its exit code is/isn't 0."""
print('Running "%s". . .' % ' '.join(command)) print 'Running "%s". . .' % ' '.join(command)
p = gtest_test_utils.Subprocess(command) p = gtest_test_utils.Subprocess(command)
return p.exited and p.exit_code == 0 return p.exited and p.exit_code == 0
......
...@@ -33,9 +33,9 @@ ...@@ -33,9 +33,9 @@
__author__ = 'wan@google.com (Zhanyong Wan)' __author__ = 'wan@google.com (Zhanyong Wan)'
import os
import gtest_test_utils import gtest_test_utils
COMMAND = gtest_test_utils.GetTestExecutablePath('gtest_uninitialized_test_') COMMAND = gtest_test_utils.GetTestExecutablePath('gtest_uninitialized_test_')
...@@ -46,8 +46,8 @@ def Assert(condition): ...@@ -46,8 +46,8 @@ def Assert(condition):
def AssertEq(expected, actual): def AssertEq(expected, actual):
if expected != actual: if expected != actual:
print('Expected: %s' % (expected,)) print 'Expected: %s' % (expected,)
print(' Actual: %s' % (actual,)) print ' Actual: %s' % (actual,)
raise AssertionError raise AssertionError
...@@ -56,8 +56,8 @@ def TestExitCodeAndOutput(command): ...@@ -56,8 +56,8 @@ def TestExitCodeAndOutput(command):
# Verifies that 'command' exits with code 1. # Verifies that 'command' exits with code 1.
p = gtest_test_utils.Subprocess(command) p = gtest_test_utils.Subprocess(command)
Assert(p.exited) if p.exited and p.exit_code == 0:
AssertEq(1, p.exit_code) Assert('IMPORTANT NOTICE' in p.output);
Assert('InitGoogleTest' in p.output) Assert('InitGoogleTest' in p.output)
......
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
TEST(DummyTest, Dummy) { TEST(DummyTest, Dummy) {
// This test doesn't verify anything. We just need it to create a // This test doesn't verify anything. We just need it to create a
// realistic stage for testing the behavior of Google Test when // realistic stage for testing the behavior of Google Test when
// RUN_ALL_TESTS() is called without testing::InitGoogleTest() being // RUN_ALL_TESTS() is called without
// called first. // testing::InitGoogleTest() being called first.
} }
int main() { int main() {
......
...@@ -34,9 +34,9 @@ ...@@ -34,9 +34,9 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
// Verifies that the command line flag variables can be accessed // Verifies that the command line flag variables can be accessed in
// in code once <gtest/gtest.h> has been #included. // code once "gtest/gtest.h" has been
// Do not move it after other #includes. // #included. Do not move it after other gtest #includes.
TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) { TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
bool dummy = testing::GTEST_FLAG(also_run_disabled_tests) bool dummy = testing::GTEST_FLAG(also_run_disabled_tests)
|| testing::GTEST_FLAG(break_on_failure) || testing::GTEST_FLAG(break_on_failure)
...@@ -66,15 +66,7 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) { ...@@ -66,15 +66,7 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
#include <ostream> #include <ostream>
#include "gtest/gtest-spi.h" #include "gtest/gtest-spi.h"
// Indicates that this translation unit is part of Google Test's
// implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in
// their code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
namespace testing { namespace testing {
namespace internal { namespace internal {
...@@ -546,7 +538,7 @@ TEST(CodePointToUtf8Test, CanEncode8To11Bits) { ...@@ -546,7 +538,7 @@ TEST(CodePointToUtf8Test, CanEncode8To11Bits) {
// 101 0111 0110 => 110-10101 10-110110 // 101 0111 0110 => 110-10101 10-110110
// Some compilers (e.g., GCC on MinGW) cannot handle non-ASCII codepoints // Some compilers (e.g., GCC on MinGW) cannot handle non-ASCII codepoints
// in wide strings and wide chars. In order to accomodate them, we have to // in wide strings and wide chars. In order to accommodate them, we have to
// introduce such character constants as integers. // introduce such character constants as integers.
EXPECT_EQ("\xD5\xB6", EXPECT_EQ("\xD5\xB6",
CodePointToUtf8(static_cast<wchar_t>(0x576))); CodePointToUtf8(static_cast<wchar_t>(0x576)));
...@@ -1787,7 +1779,7 @@ TEST(Int32FromEnvOrDieDeathTest, AbortsOnFailure) { ...@@ -1787,7 +1779,7 @@ TEST(Int32FromEnvOrDieDeathTest, AbortsOnFailure) {
} }
// Tests that Int32FromEnvOrDie() aborts with an error message // Tests that Int32FromEnvOrDie() aborts with an error message
// if the variable cannot be represnted by an Int32. // if the variable cannot be represented by an Int32.
TEST(Int32FromEnvOrDieDeathTest, AbortsOnInt32Overflow) { TEST(Int32FromEnvOrDieDeathTest, AbortsOnInt32Overflow) {
SetEnv(GTEST_FLAG_PREFIX_UPPER_ "VAR", "1234567891234567891234"); SetEnv(GTEST_FLAG_PREFIX_UPPER_ "VAR", "1234567891234567891234");
EXPECT_DEATH_IF_SUPPORTED( EXPECT_DEATH_IF_SUPPORTED(
...@@ -2096,7 +2088,7 @@ class UnitTestRecordPropertyTestEnvironment : public Environment { ...@@ -2096,7 +2088,7 @@ class UnitTestRecordPropertyTestEnvironment : public Environment {
}; };
// This will test property recording outside of any test or test case. // This will test property recording outside of any test or test case.
Environment* record_property_env GTEST_ATTRIBUTE_UNUSED_ = static Environment* record_property_env =
AddGlobalTestEnvironment(new UnitTestRecordPropertyTestEnvironment); AddGlobalTestEnvironment(new UnitTestRecordPropertyTestEnvironment);
// This group of tests is for predicate assertions (ASSERT_PRED*, etc) // This group of tests is for predicate assertions (ASSERT_PRED*, etc)
...@@ -2429,9 +2421,8 @@ TEST(StringAssertionTest, ASSERT_STREQ) { ...@@ -2429,9 +2421,8 @@ TEST(StringAssertionTest, ASSERT_STREQ) {
const char p2[] = "good"; const char p2[] = "good";
ASSERT_STREQ(p1, p2); ASSERT_STREQ(p1, p2);
EXPECT_FATAL_FAILURE( EXPECT_FATAL_FAILURE(ASSERT_STREQ("bad", "good"),
ASSERT_STREQ("bad", "good"), " \"bad\"\n \"good\"");
"Expected equality of these values:\n \"bad\"\n \"good\"");
} }
// Tests ASSERT_STREQ with NULL arguments. // Tests ASSERT_STREQ with NULL arguments.
...@@ -3369,7 +3360,7 @@ class NoFatalFailureTest : public Test { ...@@ -3369,7 +3360,7 @@ class NoFatalFailureTest : public Test {
void DoAssertNoFatalFailureOnFails() { void DoAssertNoFatalFailureOnFails() {
ASSERT_NO_FATAL_FAILURE(Fails()); ASSERT_NO_FATAL_FAILURE(Fails());
ADD_FAILURE() << "shold not reach here."; ADD_FAILURE() << "should not reach here.";
} }
void DoExpectNoFatalFailureOnFails() { void DoExpectNoFatalFailureOnFails() {
...@@ -3666,7 +3657,7 @@ TEST(AssertionTest, AssertFalseWithAssertionResult) { ...@@ -3666,7 +3657,7 @@ TEST(AssertionTest, AssertFalseWithAssertionResult) {
} }
#ifdef __BORLANDC__ #ifdef __BORLANDC__
// Restores warnings after previous "#pragma option push" supressed them // Restores warnings after previous "#pragma option push" suppressed them
# pragma option pop # pragma option pop
#endif #endif
...@@ -3821,7 +3812,7 @@ void TestEq1(int x) { ...@@ -3821,7 +3812,7 @@ void TestEq1(int x) {
// Tests calling a test subroutine that's not part of a fixture. // Tests calling a test subroutine that's not part of a fixture.
TEST(AssertionTest, NonFixtureSubroutine) { TEST(AssertionTest, NonFixtureSubroutine) {
EXPECT_FATAL_FAILURE(TestEq1(2), EXPECT_FATAL_FAILURE(TestEq1(2),
"Which is: 2"); " x\n Which is: 2");
} }
// An uncopyable class. // An uncopyable class.
...@@ -3960,13 +3951,13 @@ TEST(AssertionTest, AnonymousEnum) { ...@@ -3960,13 +3951,13 @@ TEST(AssertionTest, AnonymousEnum) {
// ICE's in C++Builder. // ICE's in C++Builder.
EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseB), EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseB),
"kCaseB"); " kCaseB\n Which is: ");
EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseC), EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseC),
"Which is: 42"); "\n Which is: 42");
# endif # endif
EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseC), EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseC),
"Which is: -1"); "\n Which is: -1");
} }
#endif // !GTEST_OS_MAC && !defined(__SUNPRO_CC) #endif // !GTEST_OS_MAC && !defined(__SUNPRO_CC)
...@@ -4392,7 +4383,7 @@ TEST(ExpectTest, ExpectFalseWithAssertionResult) { ...@@ -4392,7 +4383,7 @@ TEST(ExpectTest, ExpectFalseWithAssertionResult) {
} }
#ifdef __BORLANDC__ #ifdef __BORLANDC__
// Restores warnings after previous "#pragma option push" supressed them // Restores warnings after previous "#pragma option push" suppressed them
# pragma option pop # pragma option pop
#endif #endif
...@@ -4434,7 +4425,7 @@ TEST(ExpectTest, EXPECT_EQ_NULL) { ...@@ -4434,7 +4425,7 @@ TEST(ExpectTest, EXPECT_EQ_NULL) {
// A failure. // A failure.
int n = 0; int n = 0;
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(NULL, &n), EXPECT_NONFATAL_FAILURE(EXPECT_EQ(NULL, &n),
"&n\n"); " &n\n Which is:");
} }
#endif // GTEST_CAN_COMPARE_NULL #endif // GTEST_CAN_COMPARE_NULL
...@@ -4450,7 +4441,7 @@ TEST(ExpectTest, EXPECT_EQ_0) { ...@@ -4450,7 +4441,7 @@ TEST(ExpectTest, EXPECT_EQ_0) {
// A failure. // A failure.
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(0, 5.6), EXPECT_NONFATAL_FAILURE(EXPECT_EQ(0, 5.6),
"Expected equality of these values:\n 0\n 5.6"); " 0\n 5.6");
} }
// Tests EXPECT_NE. // Tests EXPECT_NE.
...@@ -4550,7 +4541,7 @@ TEST(ExpectTest, EXPECT_ANY_THROW) { ...@@ -4550,7 +4541,7 @@ TEST(ExpectTest, EXPECT_ANY_THROW) {
TEST(ExpectTest, ExpectPrecedence) { TEST(ExpectTest, ExpectPrecedence) {
EXPECT_EQ(1 < 2, true); EXPECT_EQ(1 < 2, true);
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(true, true && false), EXPECT_NONFATAL_FAILURE(EXPECT_EQ(true, true && false),
"true && false"); " true && false\n Which is: false");
} }
...@@ -4697,14 +4688,14 @@ TEST(EqAssertionTest, Bool) { ...@@ -4697,14 +4688,14 @@ TEST(EqAssertionTest, Bool) {
EXPECT_FATAL_FAILURE({ EXPECT_FATAL_FAILURE({
bool false_value = false; bool false_value = false;
ASSERT_EQ(false_value, true); ASSERT_EQ(false_value, true);
}, "Which is: false"); }, " false_value\n Which is: false\n true");
} }
// Tests using int values in {EXPECT|ASSERT}_EQ. // Tests using int values in {EXPECT|ASSERT}_EQ.
TEST(EqAssertionTest, Int) { TEST(EqAssertionTest, Int) {
ASSERT_EQ(32, 32); ASSERT_EQ(32, 32);
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(32, 33), EXPECT_NONFATAL_FAILURE(EXPECT_EQ(32, 33),
"33"); " 32\n 33");
} }
// Tests using time_t values in {EXPECT|ASSERT}_EQ. // Tests using time_t values in {EXPECT|ASSERT}_EQ.
...@@ -4721,9 +4712,9 @@ TEST(EqAssertionTest, Char) { ...@@ -4721,9 +4712,9 @@ TEST(EqAssertionTest, Char) {
ASSERT_EQ('z', 'z'); ASSERT_EQ('z', 'z');
const char ch = 'b'; const char ch = 'b';
EXPECT_NONFATAL_FAILURE(EXPECT_EQ('\0', ch), EXPECT_NONFATAL_FAILURE(EXPECT_EQ('\0', ch),
"ch"); " ch\n Which is: 'b'");
EXPECT_NONFATAL_FAILURE(EXPECT_EQ('a', ch), EXPECT_NONFATAL_FAILURE(EXPECT_EQ('a', ch),
"ch"); " ch\n Which is: 'b'");
} }
// Tests using wchar_t values in {EXPECT|ASSERT}_EQ. // Tests using wchar_t values in {EXPECT|ASSERT}_EQ.
...@@ -4743,7 +4734,7 @@ TEST(EqAssertionTest, WideChar) { ...@@ -4743,7 +4734,7 @@ TEST(EqAssertionTest, WideChar) {
"wchar"); "wchar");
wchar = 0x8119; wchar = 0x8119;
EXPECT_FATAL_FAILURE(ASSERT_EQ(static_cast<wchar_t>(0x8120), wchar), EXPECT_FATAL_FAILURE(ASSERT_EQ(static_cast<wchar_t>(0x8120), wchar),
"wchar"); " wchar\n Which is: L'");
} }
// Tests using ::std::string values in {EXPECT|ASSERT}_EQ. // Tests using ::std::string values in {EXPECT|ASSERT}_EQ.
...@@ -4772,8 +4763,7 @@ TEST(EqAssertionTest, StdString) { ...@@ -4772,8 +4763,7 @@ TEST(EqAssertionTest, StdString) {
static ::std::string str3(str1); static ::std::string str3(str1);
str3.at(2) = '\0'; str3.at(2) = '\0';
EXPECT_FATAL_FAILURE(ASSERT_EQ(str1, str3), EXPECT_FATAL_FAILURE(ASSERT_EQ(str1, str3),
" str3\n" " str3\n Which is: \"A \\0 in the middle\"");
" Which is: \"A \\0 in the middle\"");
} }
#if GTEST_HAS_STD_WSTRING #if GTEST_HAS_STD_WSTRING
...@@ -4893,9 +4883,9 @@ TEST(EqAssertionTest, CharPointer) { ...@@ -4893,9 +4883,9 @@ TEST(EqAssertionTest, CharPointer) {
ASSERT_EQ(p1, p1); ASSERT_EQ(p1, p1);
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p0, p2), EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p0, p2),
"p2"); " p2\n Which is:");
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, p2), EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, p2),
"p2"); " p2\n Which is:");
EXPECT_FATAL_FAILURE(ASSERT_EQ(reinterpret_cast<char*>(0x1234), EXPECT_FATAL_FAILURE(ASSERT_EQ(reinterpret_cast<char*>(0x1234),
reinterpret_cast<char*>(0xABC0)), reinterpret_cast<char*>(0xABC0)),
"ABC0"); "ABC0");
...@@ -4915,9 +4905,9 @@ TEST(EqAssertionTest, WideCharPointer) { ...@@ -4915,9 +4905,9 @@ TEST(EqAssertionTest, WideCharPointer) {
EXPECT_EQ(p0, p0); EXPECT_EQ(p0, p0);
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p0, p2), EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p0, p2),
"p2"); " p2\n Which is:");
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, p2), EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, p2),
"p2"); " p2\n Which is:");
void* pv3 = (void*)0x1234; // NOLINT void* pv3 = (void*)0x1234; // NOLINT
void* pv4 = (void*)0xABC0; // NOLINT void* pv4 = (void*)0xABC0; // NOLINT
const wchar_t* p3 = reinterpret_cast<const wchar_t*>(pv3); const wchar_t* p3 = reinterpret_cast<const wchar_t*>(pv3);
...@@ -5462,7 +5452,8 @@ TEST_F(SetUpTestCaseTest, Test2) { ...@@ -5462,7 +5452,8 @@ TEST_F(SetUpTestCaseTest, Test2) {
EXPECT_STREQ("123", shared_resource_); EXPECT_STREQ("123", shared_resource_);
} }
// The InitGoogleTestTest test case tests testing::InitGoogleTest().
// The ParseFlagsTest test case tests ParseGoogleTestFlagsOnly.
// The Flags struct stores a copy of all Google Test flags. // The Flags struct stores a copy of all Google Test flags.
struct Flags { struct Flags {
...@@ -5548,8 +5539,8 @@ struct Flags { ...@@ -5548,8 +5539,8 @@ struct Flags {
return flags; return flags;
} }
// Creates a Flags struct where the gtest_random_seed flag has // Creates a Flags struct where the gtest_random_seed flag has the given
// the given value. // value.
static Flags RandomSeed(Int32 random_seed) { static Flags RandomSeed(Int32 random_seed) {
Flags flags; Flags flags;
flags.random_seed = random_seed; flags.random_seed = random_seed;
...@@ -5564,8 +5555,8 @@ struct Flags { ...@@ -5564,8 +5555,8 @@ struct Flags {
return flags; return flags;
} }
// Creates a Flags struct where the gtest_shuffle flag has // Creates a Flags struct where the gtest_shuffle flag has the given
// the given value. // value.
static Flags Shuffle(bool shuffle) { static Flags Shuffle(bool shuffle) {
Flags flags; Flags flags;
flags.shuffle = shuffle; flags.shuffle = shuffle;
...@@ -5613,8 +5604,8 @@ struct Flags { ...@@ -5613,8 +5604,8 @@ struct Flags {
bool throw_on_failure; bool throw_on_failure;
}; };
// Fixture for testing InitGoogleTest(). // Fixture for testing ParseGoogleTestFlagsOnly().
class InitGoogleTestTest : public Test { class ParseFlagsTest : public Test {
protected: protected:
// Clears the flags before each test. // Clears the flags before each test.
virtual void SetUp() { virtual void SetUp() {
...@@ -5675,16 +5666,16 @@ class InitGoogleTestTest : public Test { ...@@ -5675,16 +5666,16 @@ class InitGoogleTestTest : public Test {
const bool saved_help_flag = ::testing::internal::g_help_flag; const bool saved_help_flag = ::testing::internal::g_help_flag;
::testing::internal::g_help_flag = false; ::testing::internal::g_help_flag = false;
#if GTEST_HAS_STREAM_REDIRECTION # if GTEST_HAS_STREAM_REDIRECTION
CaptureStdout(); CaptureStdout();
#endif # endif
// Parses the command line. // Parses the command line.
internal::ParseGoogleTestFlagsOnly(&argc1, const_cast<CharType**>(argv1)); internal::ParseGoogleTestFlagsOnly(&argc1, const_cast<CharType**>(argv1));
#if GTEST_HAS_STREAM_REDIRECTION # if GTEST_HAS_STREAM_REDIRECTION
const std::string captured_stdout = GetCapturedStdout(); const std::string captured_stdout = GetCapturedStdout();
#endif # endif
// Verifies the flag values. // Verifies the flag values.
CheckFlags(expected); CheckFlags(expected);
...@@ -5697,7 +5688,7 @@ class InitGoogleTestTest : public Test { ...@@ -5697,7 +5688,7 @@ class InitGoogleTestTest : public Test {
// help message for the flags it recognizes. // help message for the flags it recognizes.
EXPECT_EQ(should_print_help, ::testing::internal::g_help_flag); EXPECT_EQ(should_print_help, ::testing::internal::g_help_flag);
#if GTEST_HAS_STREAM_REDIRECTION # if GTEST_HAS_STREAM_REDIRECTION
const char* const expected_help_fragment = const char* const expected_help_fragment =
"This program contains tests written using"; "This program contains tests written using";
if (should_print_help) { if (should_print_help) {
...@@ -5706,7 +5697,7 @@ class InitGoogleTestTest : public Test { ...@@ -5706,7 +5697,7 @@ class InitGoogleTestTest : public Test {
EXPECT_PRED_FORMAT2(IsNotSubstring, EXPECT_PRED_FORMAT2(IsNotSubstring,
expected_help_fragment, captured_stdout); expected_help_fragment, captured_stdout);
} }
#endif // GTEST_HAS_STREAM_REDIRECTION # endif // GTEST_HAS_STREAM_REDIRECTION
::testing::internal::g_help_flag = saved_help_flag; ::testing::internal::g_help_flag = saved_help_flag;
} }
...@@ -5714,14 +5705,14 @@ class InitGoogleTestTest : public Test { ...@@ -5714,14 +5705,14 @@ class InitGoogleTestTest : public Test {
// This macro wraps TestParsingFlags s.t. the user doesn't need // This macro wraps TestParsingFlags s.t. the user doesn't need
// to specify the array sizes. // to specify the array sizes.
#define GTEST_TEST_PARSING_FLAGS_(argv1, argv2, expected, should_print_help) \ # define GTEST_TEST_PARSING_FLAGS_(argv1, argv2, expected, should_print_help) \
TestParsingFlags(sizeof(argv1)/sizeof(*argv1) - 1, argv1, \ TestParsingFlags(sizeof(argv1)/sizeof(*argv1) - 1, argv1, \
sizeof(argv2)/sizeof(*argv2) - 1, argv2, \ sizeof(argv2)/sizeof(*argv2) - 1, argv2, \
expected, should_print_help) expected, should_print_help)
}; };
// Tests parsing an empty command line. // Tests parsing an empty command line.
TEST_F(InitGoogleTestTest, Empty) { TEST_F(ParseFlagsTest, Empty) {
const char* argv[] = { const char* argv[] = {
NULL NULL
}; };
...@@ -5734,7 +5725,7 @@ TEST_F(InitGoogleTestTest, Empty) { ...@@ -5734,7 +5725,7 @@ TEST_F(InitGoogleTestTest, Empty) {
} }
// Tests parsing a command line that has no flag. // Tests parsing a command line that has no flag.
TEST_F(InitGoogleTestTest, NoFlag) { TEST_F(ParseFlagsTest, NoFlag) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
NULL NULL
...@@ -5749,7 +5740,7 @@ TEST_F(InitGoogleTestTest, NoFlag) { ...@@ -5749,7 +5740,7 @@ TEST_F(InitGoogleTestTest, NoFlag) {
} }
// Tests parsing a bad --gtest_filter flag. // Tests parsing a bad --gtest_filter flag.
TEST_F(InitGoogleTestTest, FilterBad) { TEST_F(ParseFlagsTest, FilterBad) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_filter", "--gtest_filter",
...@@ -5766,7 +5757,7 @@ TEST_F(InitGoogleTestTest, FilterBad) { ...@@ -5766,7 +5757,7 @@ TEST_F(InitGoogleTestTest, FilterBad) {
} }
// Tests parsing an empty --gtest_filter flag. // Tests parsing an empty --gtest_filter flag.
TEST_F(InitGoogleTestTest, FilterEmpty) { TEST_F(ParseFlagsTest, FilterEmpty) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_filter=", "--gtest_filter=",
...@@ -5782,7 +5773,7 @@ TEST_F(InitGoogleTestTest, FilterEmpty) { ...@@ -5782,7 +5773,7 @@ TEST_F(InitGoogleTestTest, FilterEmpty) {
} }
// Tests parsing a non-empty --gtest_filter flag. // Tests parsing a non-empty --gtest_filter flag.
TEST_F(InitGoogleTestTest, FilterNonEmpty) { TEST_F(ParseFlagsTest, FilterNonEmpty) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_filter=abc", "--gtest_filter=abc",
...@@ -5798,7 +5789,7 @@ TEST_F(InitGoogleTestTest, FilterNonEmpty) { ...@@ -5798,7 +5789,7 @@ TEST_F(InitGoogleTestTest, FilterNonEmpty) {
} }
// Tests parsing --gtest_break_on_failure. // Tests parsing --gtest_break_on_failure.
TEST_F(InitGoogleTestTest, BreakOnFailureWithoutValue) { TEST_F(ParseFlagsTest, BreakOnFailureWithoutValue) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_break_on_failure", "--gtest_break_on_failure",
...@@ -5814,7 +5805,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureWithoutValue) { ...@@ -5814,7 +5805,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureWithoutValue) {
} }
// Tests parsing --gtest_break_on_failure=0. // Tests parsing --gtest_break_on_failure=0.
TEST_F(InitGoogleTestTest, BreakOnFailureFalse_0) { TEST_F(ParseFlagsTest, BreakOnFailureFalse_0) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_break_on_failure=0", "--gtest_break_on_failure=0",
...@@ -5830,7 +5821,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureFalse_0) { ...@@ -5830,7 +5821,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureFalse_0) {
} }
// Tests parsing --gtest_break_on_failure=f. // Tests parsing --gtest_break_on_failure=f.
TEST_F(InitGoogleTestTest, BreakOnFailureFalse_f) { TEST_F(ParseFlagsTest, BreakOnFailureFalse_f) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_break_on_failure=f", "--gtest_break_on_failure=f",
...@@ -5846,7 +5837,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureFalse_f) { ...@@ -5846,7 +5837,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureFalse_f) {
} }
// Tests parsing --gtest_break_on_failure=F. // Tests parsing --gtest_break_on_failure=F.
TEST_F(InitGoogleTestTest, BreakOnFailureFalse_F) { TEST_F(ParseFlagsTest, BreakOnFailureFalse_F) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_break_on_failure=F", "--gtest_break_on_failure=F",
...@@ -5863,7 +5854,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureFalse_F) { ...@@ -5863,7 +5854,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureFalse_F) {
// Tests parsing a --gtest_break_on_failure flag that has a "true" // Tests parsing a --gtest_break_on_failure flag that has a "true"
// definition. // definition.
TEST_F(InitGoogleTestTest, BreakOnFailureTrue) { TEST_F(ParseFlagsTest, BreakOnFailureTrue) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_break_on_failure=1", "--gtest_break_on_failure=1",
...@@ -5879,7 +5870,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureTrue) { ...@@ -5879,7 +5870,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureTrue) {
} }
// Tests parsing --gtest_catch_exceptions. // Tests parsing --gtest_catch_exceptions.
TEST_F(InitGoogleTestTest, CatchExceptions) { TEST_F(ParseFlagsTest, CatchExceptions) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_catch_exceptions", "--gtest_catch_exceptions",
...@@ -5895,7 +5886,7 @@ TEST_F(InitGoogleTestTest, CatchExceptions) { ...@@ -5895,7 +5886,7 @@ TEST_F(InitGoogleTestTest, CatchExceptions) {
} }
// Tests parsing --gtest_death_test_use_fork. // Tests parsing --gtest_death_test_use_fork.
TEST_F(InitGoogleTestTest, DeathTestUseFork) { TEST_F(ParseFlagsTest, DeathTestUseFork) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_death_test_use_fork", "--gtest_death_test_use_fork",
...@@ -5912,7 +5903,7 @@ TEST_F(InitGoogleTestTest, DeathTestUseFork) { ...@@ -5912,7 +5903,7 @@ TEST_F(InitGoogleTestTest, DeathTestUseFork) {
// Tests having the same flag twice with different values. The // Tests having the same flag twice with different values. The
// expected behavior is that the one coming last takes precedence. // expected behavior is that the one coming last takes precedence.
TEST_F(InitGoogleTestTest, DuplicatedFlags) { TEST_F(ParseFlagsTest, DuplicatedFlags) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_filter=a", "--gtest_filter=a",
...@@ -5929,7 +5920,7 @@ TEST_F(InitGoogleTestTest, DuplicatedFlags) { ...@@ -5929,7 +5920,7 @@ TEST_F(InitGoogleTestTest, DuplicatedFlags) {
} }
// Tests having an unrecognized flag on the command line. // Tests having an unrecognized flag on the command line.
TEST_F(InitGoogleTestTest, UnrecognizedFlag) { TEST_F(ParseFlagsTest, UnrecognizedFlag) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_break_on_failure", "--gtest_break_on_failure",
...@@ -5951,7 +5942,7 @@ TEST_F(InitGoogleTestTest, UnrecognizedFlag) { ...@@ -5951,7 +5942,7 @@ TEST_F(InitGoogleTestTest, UnrecognizedFlag) {
} }
// Tests having a --gtest_list_tests flag // Tests having a --gtest_list_tests flag
TEST_F(InitGoogleTestTest, ListTestsFlag) { TEST_F(ParseFlagsTest, ListTestsFlag) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_list_tests", "--gtest_list_tests",
...@@ -5967,7 +5958,7 @@ TEST_F(InitGoogleTestTest, ListTestsFlag) { ...@@ -5967,7 +5958,7 @@ TEST_F(InitGoogleTestTest, ListTestsFlag) {
} }
// Tests having a --gtest_list_tests flag with a "true" value // Tests having a --gtest_list_tests flag with a "true" value
TEST_F(InitGoogleTestTest, ListTestsTrue) { TEST_F(ParseFlagsTest, ListTestsTrue) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_list_tests=1", "--gtest_list_tests=1",
...@@ -5983,7 +5974,7 @@ TEST_F(InitGoogleTestTest, ListTestsTrue) { ...@@ -5983,7 +5974,7 @@ TEST_F(InitGoogleTestTest, ListTestsTrue) {
} }
// Tests having a --gtest_list_tests flag with a "false" value // Tests having a --gtest_list_tests flag with a "false" value
TEST_F(InitGoogleTestTest, ListTestsFalse) { TEST_F(ParseFlagsTest, ListTestsFalse) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_list_tests=0", "--gtest_list_tests=0",
...@@ -5999,7 +5990,7 @@ TEST_F(InitGoogleTestTest, ListTestsFalse) { ...@@ -5999,7 +5990,7 @@ TEST_F(InitGoogleTestTest, ListTestsFalse) {
} }
// Tests parsing --gtest_list_tests=f. // Tests parsing --gtest_list_tests=f.
TEST_F(InitGoogleTestTest, ListTestsFalse_f) { TEST_F(ParseFlagsTest, ListTestsFalse_f) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_list_tests=f", "--gtest_list_tests=f",
...@@ -6015,7 +6006,7 @@ TEST_F(InitGoogleTestTest, ListTestsFalse_f) { ...@@ -6015,7 +6006,7 @@ TEST_F(InitGoogleTestTest, ListTestsFalse_f) {
} }
// Tests parsing --gtest_list_tests=F. // Tests parsing --gtest_list_tests=F.
TEST_F(InitGoogleTestTest, ListTestsFalse_F) { TEST_F(ParseFlagsTest, ListTestsFalse_F) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_list_tests=F", "--gtest_list_tests=F",
...@@ -6031,7 +6022,7 @@ TEST_F(InitGoogleTestTest, ListTestsFalse_F) { ...@@ -6031,7 +6022,7 @@ TEST_F(InitGoogleTestTest, ListTestsFalse_F) {
} }
// Tests parsing --gtest_output (invalid). // Tests parsing --gtest_output (invalid).
TEST_F(InitGoogleTestTest, OutputEmpty) { TEST_F(ParseFlagsTest, OutputEmpty) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_output", "--gtest_output",
...@@ -6048,7 +6039,7 @@ TEST_F(InitGoogleTestTest, OutputEmpty) { ...@@ -6048,7 +6039,7 @@ TEST_F(InitGoogleTestTest, OutputEmpty) {
} }
// Tests parsing --gtest_output=xml // Tests parsing --gtest_output=xml
TEST_F(InitGoogleTestTest, OutputXml) { TEST_F(ParseFlagsTest, OutputXml) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_output=xml", "--gtest_output=xml",
...@@ -6064,7 +6055,7 @@ TEST_F(InitGoogleTestTest, OutputXml) { ...@@ -6064,7 +6055,7 @@ TEST_F(InitGoogleTestTest, OutputXml) {
} }
// Tests parsing --gtest_output=xml:file // Tests parsing --gtest_output=xml:file
TEST_F(InitGoogleTestTest, OutputXmlFile) { TEST_F(ParseFlagsTest, OutputXmlFile) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_output=xml:file", "--gtest_output=xml:file",
...@@ -6080,7 +6071,7 @@ TEST_F(InitGoogleTestTest, OutputXmlFile) { ...@@ -6080,7 +6071,7 @@ TEST_F(InitGoogleTestTest, OutputXmlFile) {
} }
// Tests parsing --gtest_output=xml:directory/path/ // Tests parsing --gtest_output=xml:directory/path/
TEST_F(InitGoogleTestTest, OutputXmlDirectory) { TEST_F(ParseFlagsTest, OutputXmlDirectory) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_output=xml:directory/path/", "--gtest_output=xml:directory/path/",
...@@ -6097,7 +6088,7 @@ TEST_F(InitGoogleTestTest, OutputXmlDirectory) { ...@@ -6097,7 +6088,7 @@ TEST_F(InitGoogleTestTest, OutputXmlDirectory) {
} }
// Tests having a --gtest_print_time flag // Tests having a --gtest_print_time flag
TEST_F(InitGoogleTestTest, PrintTimeFlag) { TEST_F(ParseFlagsTest, PrintTimeFlag) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_print_time", "--gtest_print_time",
...@@ -6113,7 +6104,7 @@ TEST_F(InitGoogleTestTest, PrintTimeFlag) { ...@@ -6113,7 +6104,7 @@ TEST_F(InitGoogleTestTest, PrintTimeFlag) {
} }
// Tests having a --gtest_print_time flag with a "true" value // Tests having a --gtest_print_time flag with a "true" value
TEST_F(InitGoogleTestTest, PrintTimeTrue) { TEST_F(ParseFlagsTest, PrintTimeTrue) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_print_time=1", "--gtest_print_time=1",
...@@ -6129,7 +6120,7 @@ TEST_F(InitGoogleTestTest, PrintTimeTrue) { ...@@ -6129,7 +6120,7 @@ TEST_F(InitGoogleTestTest, PrintTimeTrue) {
} }
// Tests having a --gtest_print_time flag with a "false" value // Tests having a --gtest_print_time flag with a "false" value
TEST_F(InitGoogleTestTest, PrintTimeFalse) { TEST_F(ParseFlagsTest, PrintTimeFalse) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_print_time=0", "--gtest_print_time=0",
...@@ -6145,7 +6136,7 @@ TEST_F(InitGoogleTestTest, PrintTimeFalse) { ...@@ -6145,7 +6136,7 @@ TEST_F(InitGoogleTestTest, PrintTimeFalse) {
} }
// Tests parsing --gtest_print_time=f. // Tests parsing --gtest_print_time=f.
TEST_F(InitGoogleTestTest, PrintTimeFalse_f) { TEST_F(ParseFlagsTest, PrintTimeFalse_f) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_print_time=f", "--gtest_print_time=f",
...@@ -6161,7 +6152,7 @@ TEST_F(InitGoogleTestTest, PrintTimeFalse_f) { ...@@ -6161,7 +6152,7 @@ TEST_F(InitGoogleTestTest, PrintTimeFalse_f) {
} }
// Tests parsing --gtest_print_time=F. // Tests parsing --gtest_print_time=F.
TEST_F(InitGoogleTestTest, PrintTimeFalse_F) { TEST_F(ParseFlagsTest, PrintTimeFalse_F) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_print_time=F", "--gtest_print_time=F",
...@@ -6177,7 +6168,7 @@ TEST_F(InitGoogleTestTest, PrintTimeFalse_F) { ...@@ -6177,7 +6168,7 @@ TEST_F(InitGoogleTestTest, PrintTimeFalse_F) {
} }
// Tests parsing --gtest_random_seed=number // Tests parsing --gtest_random_seed=number
TEST_F(InitGoogleTestTest, RandomSeed) { TEST_F(ParseFlagsTest, RandomSeed) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_random_seed=1000", "--gtest_random_seed=1000",
...@@ -6193,7 +6184,7 @@ TEST_F(InitGoogleTestTest, RandomSeed) { ...@@ -6193,7 +6184,7 @@ TEST_F(InitGoogleTestTest, RandomSeed) {
} }
// Tests parsing --gtest_repeat=number // Tests parsing --gtest_repeat=number
TEST_F(InitGoogleTestTest, Repeat) { TEST_F(ParseFlagsTest, Repeat) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_repeat=1000", "--gtest_repeat=1000",
...@@ -6209,7 +6200,7 @@ TEST_F(InitGoogleTestTest, Repeat) { ...@@ -6209,7 +6200,7 @@ TEST_F(InitGoogleTestTest, Repeat) {
} }
// Tests having a --gtest_also_run_disabled_tests flag // Tests having a --gtest_also_run_disabled_tests flag
TEST_F(InitGoogleTestTest, AlsoRunDisabledTestsFlag) { TEST_F(ParseFlagsTest, AlsoRunDisabledTestsFlag) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_also_run_disabled_tests", "--gtest_also_run_disabled_tests",
...@@ -6226,7 +6217,7 @@ TEST_F(InitGoogleTestTest, AlsoRunDisabledTestsFlag) { ...@@ -6226,7 +6217,7 @@ TEST_F(InitGoogleTestTest, AlsoRunDisabledTestsFlag) {
} }
// Tests having a --gtest_also_run_disabled_tests flag with a "true" value // Tests having a --gtest_also_run_disabled_tests flag with a "true" value
TEST_F(InitGoogleTestTest, AlsoRunDisabledTestsTrue) { TEST_F(ParseFlagsTest, AlsoRunDisabledTestsTrue) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_also_run_disabled_tests=1", "--gtest_also_run_disabled_tests=1",
...@@ -6243,7 +6234,7 @@ TEST_F(InitGoogleTestTest, AlsoRunDisabledTestsTrue) { ...@@ -6243,7 +6234,7 @@ TEST_F(InitGoogleTestTest, AlsoRunDisabledTestsTrue) {
} }
// Tests having a --gtest_also_run_disabled_tests flag with a "false" value // Tests having a --gtest_also_run_disabled_tests flag with a "false" value
TEST_F(InitGoogleTestTest, AlsoRunDisabledTestsFalse) { TEST_F(ParseFlagsTest, AlsoRunDisabledTestsFalse) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_also_run_disabled_tests=0", "--gtest_also_run_disabled_tests=0",
...@@ -6260,7 +6251,7 @@ TEST_F(InitGoogleTestTest, AlsoRunDisabledTestsFalse) { ...@@ -6260,7 +6251,7 @@ TEST_F(InitGoogleTestTest, AlsoRunDisabledTestsFalse) {
} }
// Tests parsing --gtest_shuffle. // Tests parsing --gtest_shuffle.
TEST_F(InitGoogleTestTest, ShuffleWithoutValue) { TEST_F(ParseFlagsTest, ShuffleWithoutValue) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_shuffle", "--gtest_shuffle",
...@@ -6276,7 +6267,7 @@ TEST_F(InitGoogleTestTest, ShuffleWithoutValue) { ...@@ -6276,7 +6267,7 @@ TEST_F(InitGoogleTestTest, ShuffleWithoutValue) {
} }
// Tests parsing --gtest_shuffle=0. // Tests parsing --gtest_shuffle=0.
TEST_F(InitGoogleTestTest, ShuffleFalse_0) { TEST_F(ParseFlagsTest, ShuffleFalse_0) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_shuffle=0", "--gtest_shuffle=0",
...@@ -6291,9 +6282,8 @@ TEST_F(InitGoogleTestTest, ShuffleFalse_0) { ...@@ -6291,9 +6282,8 @@ TEST_F(InitGoogleTestTest, ShuffleFalse_0) {
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Shuffle(false), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Shuffle(false), false);
} }
// Tests parsing a --gtest_shuffle flag that has a "true" // Tests parsing a --gtest_shuffle flag that has a "true" definition.
// definition. TEST_F(ParseFlagsTest, ShuffleTrue) {
TEST_F(InitGoogleTestTest, ShuffleTrue) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_shuffle=1", "--gtest_shuffle=1",
...@@ -6309,7 +6299,7 @@ TEST_F(InitGoogleTestTest, ShuffleTrue) { ...@@ -6309,7 +6299,7 @@ TEST_F(InitGoogleTestTest, ShuffleTrue) {
} }
// Tests parsing --gtest_stack_trace_depth=number. // Tests parsing --gtest_stack_trace_depth=number.
TEST_F(InitGoogleTestTest, StackTraceDepth) { TEST_F(ParseFlagsTest, StackTraceDepth) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_stack_trace_depth=5", "--gtest_stack_trace_depth=5",
...@@ -6324,7 +6314,7 @@ TEST_F(InitGoogleTestTest, StackTraceDepth) { ...@@ -6324,7 +6314,7 @@ TEST_F(InitGoogleTestTest, StackTraceDepth) {
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::StackTraceDepth(5), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::StackTraceDepth(5), false);
} }
TEST_F(InitGoogleTestTest, StreamResultTo) { TEST_F(ParseFlagsTest, StreamResultTo) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_stream_result_to=localhost:1234", "--gtest_stream_result_to=localhost:1234",
...@@ -6341,7 +6331,7 @@ TEST_F(InitGoogleTestTest, StreamResultTo) { ...@@ -6341,7 +6331,7 @@ TEST_F(InitGoogleTestTest, StreamResultTo) {
} }
// Tests parsing --gtest_throw_on_failure. // Tests parsing --gtest_throw_on_failure.
TEST_F(InitGoogleTestTest, ThrowOnFailureWithoutValue) { TEST_F(ParseFlagsTest, ThrowOnFailureWithoutValue) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_throw_on_failure", "--gtest_throw_on_failure",
...@@ -6357,7 +6347,7 @@ TEST_F(InitGoogleTestTest, ThrowOnFailureWithoutValue) { ...@@ -6357,7 +6347,7 @@ TEST_F(InitGoogleTestTest, ThrowOnFailureWithoutValue) {
} }
// Tests parsing --gtest_throw_on_failure=0. // Tests parsing --gtest_throw_on_failure=0.
TEST_F(InitGoogleTestTest, ThrowOnFailureFalse_0) { TEST_F(ParseFlagsTest, ThrowOnFailureFalse_0) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_throw_on_failure=0", "--gtest_throw_on_failure=0",
...@@ -6374,7 +6364,7 @@ TEST_F(InitGoogleTestTest, ThrowOnFailureFalse_0) { ...@@ -6374,7 +6364,7 @@ TEST_F(InitGoogleTestTest, ThrowOnFailureFalse_0) {
// Tests parsing a --gtest_throw_on_failure flag that has a "true" // Tests parsing a --gtest_throw_on_failure flag that has a "true"
// definition. // definition.
TEST_F(InitGoogleTestTest, ThrowOnFailureTrue) { TEST_F(ParseFlagsTest, ThrowOnFailureTrue) {
const char* argv[] = { const char* argv[] = {
"foo.exe", "foo.exe",
"--gtest_throw_on_failure=1", "--gtest_throw_on_failure=1",
...@@ -6389,9 +6379,9 @@ TEST_F(InitGoogleTestTest, ThrowOnFailureTrue) { ...@@ -6389,9 +6379,9 @@ TEST_F(InitGoogleTestTest, ThrowOnFailureTrue) {
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ThrowOnFailure(true), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ThrowOnFailure(true), false);
} }
#if GTEST_OS_WINDOWS # if GTEST_OS_WINDOWS
// Tests parsing wide strings. // Tests parsing wide strings.
TEST_F(InitGoogleTestTest, WideStrings) { TEST_F(ParseFlagsTest, WideStrings) {
const wchar_t* argv[] = { const wchar_t* argv[] = {
L"foo.exe", L"foo.exe",
L"--gtest_filter=Foo*", L"--gtest_filter=Foo*",
...@@ -6417,10 +6407,10 @@ TEST_F(InitGoogleTestTest, WideStrings) { ...@@ -6417,10 +6407,10 @@ TEST_F(InitGoogleTestTest, WideStrings) {
# endif // GTEST_OS_WINDOWS # endif // GTEST_OS_WINDOWS
#if GTEST_USE_OWN_FLAGFILE_FLAG_ #if GTEST_USE_OWN_FLAGFILE_FLAG_
class FlagfileTest : public InitGoogleTestTest { class FlagfileTest : public ParseFlagsTest {
public: public:
virtual void SetUp() { virtual void SetUp() {
InitGoogleTestTest::SetUp(); ParseFlagsTest::SetUp();
testdata_path_.Set(internal::FilePath( testdata_path_.Set(internal::FilePath(
testing::TempDir() + internal::GetCurrentExecutableName().string() + testing::TempDir() + internal::GetCurrentExecutableName().string() +
...@@ -6431,7 +6421,7 @@ class FlagfileTest : public InitGoogleTestTest { ...@@ -6431,7 +6421,7 @@ class FlagfileTest : public InitGoogleTestTest {
virtual void TearDown() { virtual void TearDown() {
testing::internal::posix::RmDir(testdata_path_.c_str()); testing::internal::posix::RmDir(testdata_path_.c_str());
InitGoogleTestTest::TearDown(); ParseFlagsTest::TearDown();
} }
internal::FilePath CreateFlagfile(const char* contents) { internal::FilePath CreateFlagfile(const char* contents) {
...@@ -6570,6 +6560,7 @@ TEST_F(CurrentTestInfoTest, WorksForSecondTestInATestCase) { ...@@ -6570,6 +6560,7 @@ TEST_F(CurrentTestInfoTest, WorksForSecondTestInATestCase) {
} // namespace testing } // namespace testing
// These two lines test that we can define tests in a namespace that // These two lines test that we can define tests in a namespace that
// has the name "testing" and is nested in another namespace. // has the name "testing" and is nested in another namespace.
namespace my_namespace { namespace my_namespace {
...@@ -6650,7 +6641,7 @@ TEST(StreamingAssertionsTest, Truth2) { ...@@ -6650,7 +6641,7 @@ TEST(StreamingAssertionsTest, Truth2) {
} }
#ifdef __BORLANDC__ #ifdef __BORLANDC__
// Restores warnings after previous "#pragma option push" supressed them // Restores warnings after previous "#pragma option push" suppressed them
# pragma option pop # pragma option pop
#endif #endif
...@@ -6900,14 +6891,6 @@ TEST(StaticAssertTypeEqTest, CompilesForEqualTypes) { ...@@ -6900,14 +6891,6 @@ TEST(StaticAssertTypeEqTest, CompilesForEqualTypes) {
StaticAssertTypeEq<int*, IntAlias*>(); StaticAssertTypeEq<int*, IntAlias*>();
} }
TEST(GetCurrentOsStackTraceExceptTopTest, ReturnsTheStackTrace) {
testing::UnitTest* const unit_test = testing::UnitTest::GetInstance();
// We don't have a stack walker in Google Test yet.
EXPECT_STREQ("", GetCurrentOsStackTraceExceptTop(unit_test, 0).c_str());
EXPECT_STREQ("", GetCurrentOsStackTraceExceptTop(unit_test, 1).c_str());
}
TEST(HasNonfatalFailureTest, ReturnsFalseWhenThereIsNoFailure) { TEST(HasNonfatalFailureTest, ReturnsFalseWhenThereIsNoFailure) {
EXPECT_FALSE(HasNonfatalFailure()); EXPECT_FALSE(HasNonfatalFailure());
} }
...@@ -7667,7 +7650,7 @@ TEST(NativeArrayTest, MethodsWork) { ...@@ -7667,7 +7650,7 @@ TEST(NativeArrayTest, MethodsWork) {
EXPECT_EQ(0, *it); EXPECT_EQ(0, *it);
++it; ++it;
EXPECT_EQ(1, *it); EXPECT_EQ(1, *it);
++it; it++;
EXPECT_EQ(2, *it); EXPECT_EQ(2, *it);
++it; ++it;
EXPECT_EQ(na.end(), it); EXPECT_EQ(na.end(), it);
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// //
// Author: keith.ray@gmail.com (Keith Ray)
// //
// gtest_xml_outfile1_test_ writes some xml via TestProperty used by // gtest_xml_outfile1_test_ writes some xml via TestProperty used by
// gtest_xml_outfiles_test.py // gtest_xml_outfiles_test.py
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// //
// Author: keith.ray@gmail.com (Keith Ray)
// //
// gtest_xml_outfile2_test_ writes some xml via TestProperty used by // gtest_xml_outfile2_test_ writes some xml via TestProperty used by
// gtest_xml_outfiles_test.py // gtest_xml_outfiles_test.py
......
...@@ -31,15 +31,11 @@ ...@@ -31,15 +31,11 @@
"""Unit test for the gtest_xml_output module.""" """Unit test for the gtest_xml_output module."""
__author__ = "keith.ray@gmail.com (Keith Ray)"
import os import os
from xml.dom import minidom, Node from xml.dom import minidom, Node
import gtest_test_utils import gtest_test_utils
import gtest_xml_test_utils import gtest_xml_test_utils
GTEST_OUTPUT_SUBDIR = "xml_outfiles" GTEST_OUTPUT_SUBDIR = "xml_outfiles"
GTEST_OUTPUT_1_TEST = "gtest_xml_outfile1_test_" GTEST_OUTPUT_1_TEST = "gtest_xml_outfile1_test_"
GTEST_OUTPUT_2_TEST = "gtest_xml_outfile2_test_" GTEST_OUTPUT_2_TEST = "gtest_xml_outfile2_test_"
......
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
"""Unit test for the gtest_xml_output module""" """Unit test for the gtest_xml_output module"""
__author__ = 'eefacm@gmail.com (Sean Mcafee)'
import datetime import datetime
import errno import errno
import os import os
...@@ -43,12 +41,16 @@ from xml.dom import minidom, Node ...@@ -43,12 +41,16 @@ from xml.dom import minidom, Node
import gtest_test_utils import gtest_test_utils
import gtest_xml_test_utils import gtest_xml_test_utils
GTEST_FILTER_FLAG = '--gtest_filter' GTEST_FILTER_FLAG = '--gtest_filter'
GTEST_LIST_TESTS_FLAG = '--gtest_list_tests' GTEST_LIST_TESTS_FLAG = '--gtest_list_tests'
GTEST_OUTPUT_FLAG = "--gtest_output" GTEST_OUTPUT_FLAG = '--gtest_output'
GTEST_DEFAULT_OUTPUT_FILE = "test_detail.xml" GTEST_DEFAULT_OUTPUT_FILE = 'test_detail.xml'
GTEST_PROGRAM_NAME = "gtest_xml_output_unittest_" GTEST_PROGRAM_NAME = 'gtest_xml_output_unittest_'
# The environment variables for test sharding.
TOTAL_SHARDS_ENV_VAR = 'GTEST_TOTAL_SHARDS'
SHARD_INDEX_ENV_VAR = 'GTEST_SHARD_INDEX'
SHARD_STATUS_FILE_ENV_VAR = 'GTEST_SHARD_STATUS_FILE'
SUPPORTS_STACK_TRACES = False SUPPORTS_STACK_TRACES = False
...@@ -141,6 +143,19 @@ EXPECTED_FILTERED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?> ...@@ -141,6 +143,19 @@ EXPECTED_FILTERED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?>
</testsuite> </testsuite>
</testsuites>""" </testsuites>"""
EXPECTED_SHARDED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="3" failures="0" disabled="0" errors="0" time="*" timestamp="*" name="AllTests" ad_hoc_property="42">
<testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="Succeeds" status="run" time="*" classname="SuccessfulTest"/>
</testsuite>
<testsuite name="NoFixtureTest" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="RecordProperty" status="run" time="*" classname="NoFixtureTest" key="1"/>
</testsuite>
<testsuite name="Single/ValueParamTest" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="AnotherTestThatHasValueParamAttribute/1" value_param="42" status="run" time="*" classname="Single/ValueParamTest" />
</testsuite>
</testsuites>"""
EXPECTED_EMPTY_XML = """<?xml version="1.0" encoding="UTF-8"?> EXPECTED_EMPTY_XML = """<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="0" failures="0" disabled="0" errors="0" time="*" <testsuites tests="0" failures="0" disabled="0" errors="0" time="*"
timestamp="*" name="AllTests"> timestamp="*" name="AllTests">
...@@ -182,7 +197,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): ...@@ -182,7 +197,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
Runs a test program that generates an empty XML output, and checks if Runs a test program that generates an empty XML output, and checks if
the timestamp attribute in the testsuites tag is valid. the timestamp attribute in the testsuites tag is valid.
""" """
actual = self._GetXmlOutput('gtest_no_test_unittest', [], 0) actual = self._GetXmlOutput('gtest_no_test_unittest', [], {}, 0)
date_time_str = actual.documentElement.getAttributeNode('timestamp').value date_time_str = actual.documentElement.getAttributeNode('timestamp').value
# datetime.strptime() is only available in Python 2.5+ so we have to # datetime.strptime() is only available in Python 2.5+ so we have to
# parse the expected datetime manually. # parse the expected datetime manually.
...@@ -212,8 +227,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): ...@@ -212,8 +227,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
'gtest_no_test_unittest') 'gtest_no_test_unittest')
try: try:
os.remove(output_file) os.remove(output_file)
except OSError: except OSError, e:
e = sys.exc_info()[1]
if e.errno != errno.ENOENT: if e.errno != errno.ENOENT:
raise raise
...@@ -263,7 +277,22 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): ...@@ -263,7 +277,22 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
self._TestXmlOutput(GTEST_PROGRAM_NAME, EXPECTED_FILTERED_TEST_XML, 0, self._TestXmlOutput(GTEST_PROGRAM_NAME, EXPECTED_FILTERED_TEST_XML, 0,
extra_args=['%s=SuccessfulTest.*' % GTEST_FILTER_FLAG]) extra_args=['%s=SuccessfulTest.*' % GTEST_FILTER_FLAG])
def _GetXmlOutput(self, gtest_prog_name, extra_args, expected_exit_code): def testShardedTestXmlOutput(self):
"""Verifies XML output when run using multiple shards.
Runs a test program that executes only one shard and verifies that tests
from other shards do not show up in the XML output.
"""
self._TestXmlOutput(
GTEST_PROGRAM_NAME,
EXPECTED_SHARDED_TEST_XML,
0,
extra_env={SHARD_INDEX_ENV_VAR: '0',
TOTAL_SHARDS_ENV_VAR: '10'})
def _GetXmlOutput(self, gtest_prog_name, extra_args, extra_env,
expected_exit_code):
""" """
Returns the xml output generated by running the program gtest_prog_name. Returns the xml output generated by running the program gtest_prog_name.
Furthermore, the program's exit code must be expected_exit_code. Furthermore, the program's exit code must be expected_exit_code.
...@@ -274,7 +303,11 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): ...@@ -274,7 +303,11 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
command = ([gtest_prog_path, '%s=xml:%s' % (GTEST_OUTPUT_FLAG, xml_path)] + command = ([gtest_prog_path, '%s=xml:%s' % (GTEST_OUTPUT_FLAG, xml_path)] +
extra_args) extra_args)
p = gtest_test_utils.Subprocess(command) environ_copy = os.environ.copy()
if extra_env:
environ_copy.update(extra_env)
p = gtest_test_utils.Subprocess(command, env=environ_copy)
if p.terminated_by_signal: if p.terminated_by_signal:
self.assert_(False, self.assert_(False,
'%s was killed by signal %d' % (gtest_prog_name, p.signal)) '%s was killed by signal %d' % (gtest_prog_name, p.signal))
...@@ -288,7 +321,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): ...@@ -288,7 +321,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
return actual return actual
def _TestXmlOutput(self, gtest_prog_name, expected_xml, def _TestXmlOutput(self, gtest_prog_name, expected_xml,
expected_exit_code, extra_args=None): expected_exit_code, extra_args=None, extra_env=None):
""" """
Asserts that the XML document generated by running the program Asserts that the XML document generated by running the program
gtest_prog_name matches expected_xml, a string containing another gtest_prog_name matches expected_xml, a string containing another
...@@ -297,7 +330,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): ...@@ -297,7 +330,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
""" """
actual = self._GetXmlOutput(gtest_prog_name, extra_args or [], actual = self._GetXmlOutput(gtest_prog_name, extra_args or [],
expected_exit_code) extra_env or {}, expected_exit_code)
expected = minidom.parseString(expected_xml) expected = minidom.parseString(expected_xml)
self.NormalizeXml(actual.documentElement) self.NormalizeXml(actual.documentElement)
self.AssertEquivalentNodes(expected.documentElement, self.AssertEquivalentNodes(expected.documentElement,
......
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Author: eefacm@gmail.com (Sean Mcafee)
// Unit test for Google Test XML output. // Unit test for Google Test XML output.
// //
// A user can specify XML output in a Google Test program to run via // A user can specify XML output in a Google Test program to run via
......
#!/usr/bin/env python
#
# Copyright 2006, Google Inc. # Copyright 2006, Google Inc.
# All rights reserved. # All rights reserved.
# #
...@@ -31,15 +29,10 @@ ...@@ -31,15 +29,10 @@
"""Unit test utilities for gtest_xml_output""" """Unit test utilities for gtest_xml_output"""
__author__ = 'eefacm@gmail.com (Sean Mcafee)'
import re import re
from xml.dom import minidom, Node from xml.dom import minidom, Node
import gtest_test_utils import gtest_test_utils
GTEST_OUTPUT_FLAG = '--gtest_output'
GTEST_DEFAULT_OUTPUT_FILE = 'test_detail.xml' GTEST_DEFAULT_OUTPUT_FILE = 'test_detail.xml'
class GTestXMLTestCase(gtest_test_utils.TestCase): class GTestXMLTestCase(gtest_test_utils.TestCase):
...@@ -101,7 +94,7 @@ class GTestXMLTestCase(gtest_test_utils.TestCase): ...@@ -101,7 +94,7 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
self.assertEquals( self.assertEquals(
len(expected_children), len(actual_children), len(expected_children), len(actual_children),
'number of child elements differ in element ' + actual_node.tagName) 'number of child elements differ in element ' + actual_node.tagName)
for child_id, child in expected_children.items(): for child_id, child in expected_children.iteritems():
self.assert_(child_id in actual_children, self.assert_(child_id in actual_children,
'<%s> is not in <%s> (in element %s)' % '<%s> is not in <%s> (in element %s)' %
(child_id, actual_children, actual_node.tagName)) (child_id, actual_children, actual_node.tagName))
...@@ -187,8 +180,8 @@ class GTestXMLTestCase(gtest_test_utils.TestCase): ...@@ -187,8 +180,8 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
# Replaces the source line information with a normalized form. # Replaces the source line information with a normalized form.
cdata = re.sub(source_line_pat, '\\1*\n', child.nodeValue) cdata = re.sub(source_line_pat, '\\1*\n', child.nodeValue)
# Removes the actual stack trace. # Removes the actual stack trace.
child.nodeValue = re.sub(r'\nStack trace:\n(.|\n)*', child.nodeValue = re.sub(r'Stack trace:\n(.|\n)*',
'', cdata) 'Stack trace:\n*', cdata)
for child in element.childNodes: for child in element.childNodes:
if child.nodeType == Node.ELEMENT_NODE: if child.nodeType == Node.ELEMENT_NODE:
self.NormalizeXml(child) self.NormalizeXml(child)
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
// //
// Author: wan@google.com (Zhanyong Wan) // Author: wan@google.com (Zhanyong Wan)
// //
// This is part of the unit test for include/gtest/gtest_prod.h. // This is part of the unit test for gtest_prod.h.
#include "production.h" #include "production.h"
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
// //
// Author: wan@google.com (Zhanyong Wan) // Author: wan@google.com (Zhanyong Wan)
// //
// This is part of the unit test for include/gtest/gtest_prod.h. // This is part of the unit test for gtest_prod.h.
#ifndef GTEST_TEST_PRODUCTION_H_ #ifndef GTEST_TEST_PRODUCTION_H_
#define GTEST_TEST_PRODUCTION_H_ #define GTEST_TEST_PRODUCTION_H_
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""A script to prepare version informtion for use the gtest Info.plist file. """A script to prepare version information for use the gtest Info.plist file.
This script extracts the version information from the configure.ac file and This script extracts the version information from the configure.ac file and
uses it to generate a header file containing the same information. The uses it to generate a header file containing the same information. The
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment