Makes the autotools scripts work on Mac OS X. Also hopefully makes gtest compile on Windows CE.

pull/496/merge
shiqian 17 years ago
parent d201456903
commit e4e9a8bd7d
  1. 12
      include/gtest/gtest-message.h
  2. 26
      include/gtest/gtest.h
  3. 12
      include/gtest/internal/gtest-filepath.h
  4. 23
      include/gtest/internal/gtest-internal.h
  5. 7
      include/gtest/internal/gtest-port.h
  6. 12
      include/gtest/internal/gtest-string.h
  7. 2
      test/gtest_output_test.py
  8. 20
      test/gtest_output_test_golden_win.txt
  9. 2
      test/gtest_repeat_test.cc
  10. 9
      test/gtest_uninitialized_test.py

@ -46,20 +46,8 @@
#ifndef GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_ #ifndef GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
#define GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_ #define GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
#if defined(__APPLE__) && !defined(GTEST_NOT_MAC_FRAMEWORK_MODE)
// When using Google Test on the Mac as a framework, all the includes will be
// in the framework headers folder along with gtest.h.
// Define GTEST_NOT_MAC_FRAMEWORK_MODE if you are building Google Test on
// the Mac and are not using it as a framework.
// More info on frameworks available here:
// http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/
// Concepts/WhatAreFrameworks.html.
#include "gtest-string.h" // NOLINT
#include "gtest-internal.h" // NOLINT
#else
#include <gtest/internal/gtest-string.h> #include <gtest/internal/gtest-string.h>
#include <gtest/internal/gtest-internal.h> #include <gtest/internal/gtest-internal.h>
#endif // defined(__APPLE__) && !defined(GTEST_NOT_MAC_FRAMEWORK_MODE)
namespace testing { namespace testing {

@ -62,26 +62,11 @@
// Windows proper with Visual C++ and MS C library (_MSC_VER && !_WIN32_WCE) and // Windows proper with Visual C++ and MS C library (_MSC_VER && !_WIN32_WCE) and
// Windows Mobile with Visual C++ and no C library (_WIN32_WCE). // Windows Mobile with Visual C++ and no C library (_WIN32_WCE).
#if defined(__APPLE__) && !defined(GTEST_NOT_MAC_FRAMEWORK_MODE)
// When using Google Test on the Mac as a framework, all the includes
// will be in the framework headers folder along with gtest.h. Define
// GTEST_NOT_MAC_FRAMEWORK_MODE if you are building Google Test on the
// Mac and are not using it as a framework. More info on frameworks
// available here:
// http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/
// Concepts/WhatAreFrameworks.html.
#include "gtest-death-test.h" // NOLINT
#include "gtest-internal.h" // NOLINT
#include "gtest-message.h" // NOLINT
#include "gtest-string.h" // NOLINT
#include "gtest_prod.h" // NOLINT
#else
#include <gtest/internal/gtest-internal.h> #include <gtest/internal/gtest-internal.h>
#include <gtest/internal/gtest-string.h> #include <gtest/internal/gtest-string.h>
#include <gtest/gtest-death-test.h> #include <gtest/gtest-death-test.h>
#include <gtest/gtest-message.h> #include <gtest/gtest-message.h>
#include <gtest/gtest_prod.h> #include <gtest/gtest_prod.h>
#endif // defined(__APPLE__) && !defined(GTEST_NOT_MAC_FRAMEWORK_MODE)
// Depending on the platform, different string classes are available. // Depending on the platform, different string classes are available.
// On Windows, ::std::string compiles only when exceptions are // On Windows, ::std::string compiles only when exceptions are
@ -964,18 +949,7 @@ class AssertHelper {
// Includes the auto-generated header that implements a family of // Includes the auto-generated header that implements a family of
// generic predicate assertion macros. // generic predicate assertion macros.
#if defined(__APPLE__) && !defined(GTEST_NOT_MAC_FRAMEWORK_MODE)
// When using Google Test on the Mac as a framework, all the includes will be
// in the framework headers folder along with gtest.h.
// Define GTEST_NOT_MAC_FRAMEWORK_MODE if you are building Google Test on
// the Mac and are not using it as a framework.
// More info on frameworks available here:
// http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/
// Concepts/WhatAreFrameworks.html.
#include "gtest_pred_impl.h" // NOLINT
#else
#include <gtest/gtest_pred_impl.h> #include <gtest/gtest_pred_impl.h>
#endif // defined(__APPLE__) && !defined(GTEST_NOT_MAC_FRAMEWORK_MODE)
// Macros for testing equalities and inequalities. // Macros for testing equalities and inequalities.
// //

@ -40,19 +40,7 @@
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_ #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
#if defined(__APPLE__) && !defined(GTEST_NOT_MAC_FRAMEWORK_MODE)
// When using Google Test on the Mac as a framework, all the includes will be
// in the framework headers folder along with gtest.h.
// Define GTEST_NOT_MAC_FRAMEWORK_MODE if you are building Google Test on
// the Mac and are not using it as a framework.
// More info on frameworks available here:
// http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/
// Concepts/WhatAreFrameworks.html.
#include "gtest-string.h" // NOLINT
#else
#include <gtest/internal/gtest-string.h> #include <gtest/internal/gtest-string.h>
#endif // defined(__APPLE__) && !defined(GTEST_NOT_MAC_FRAMEWORK_MODE)
namespace testing { namespace testing {
namespace internal { namespace internal {

@ -37,18 +37,7 @@
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_ #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
#if defined(__APPLE__) && !defined(GTEST_NOT_MAC_FRAMEWORK_MODE)
// When using Google Test on the Mac as a framework, all the includes will be
// in the framework headers folder along with gtest.h.
// Define GTEST_NOT_MAC_FRAMEWORK_MODE if you are building Google Test on
// the Mac and are not using it as a framework.
// More info on frameworks available here:
// http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/
// Concepts/WhatAreFrameworks.html.
#include "gtest-port.h" // NOLINT
#else
#include <gtest/internal/gtest-port.h> #include <gtest/internal/gtest-port.h>
#endif // defined(__APPLE__) && !defined(GTEST_NOT_MAC_FRAMEWORK_MODE)
#ifdef GTEST_OS_LINUX #ifdef GTEST_OS_LINUX
#include <stdlib.h> #include <stdlib.h>
@ -60,20 +49,8 @@
#include <iomanip> // NOLINT #include <iomanip> // NOLINT
#include <limits> // NOLINT #include <limits> // NOLINT
#if defined(__APPLE__) && !defined(GTEST_NOT_MAC_FRAMEWORK_MODE)
// When using Google Test on the Mac as a framework, all the includes will be
// in the framework headers folder along with gtest.h.
// Define GTEST_NOT_MAC_FRAMEWORK_MODE if you are building Google Test on
// the Mac and are not using it as a framework.
// More info on frameworks available here:
// http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/
// Concepts/WhatAreFrameworks.html.
#include "gtest-string.h" // NOLINT
#include "gtest-filepath.h" // NOLINT
#else
#include <gtest/internal/gtest-string.h> #include <gtest/internal/gtest-string.h>
#include <gtest/internal/gtest-filepath.h> #include <gtest/internal/gtest-filepath.h>
#endif // defined(__APPLE__) && !defined(GTEST_NOT_MAC_FRAMEWORK_MODE)
// Due to C++ preprocessor weirdness, we need double indirection to // Due to C++ preprocessor weirdness, we need double indirection to
// concatenate two tokens when one of them is __LINE__. Writing // concatenate two tokens when one of them is __LINE__. Writing

@ -124,8 +124,6 @@
// Int32FromGTestEnv() - parses an Int32 environment variable. // Int32FromGTestEnv() - parses an Int32 environment variable.
// StringFromGTestEnv() - parses a string environment variable. // StringFromGTestEnv() - parses a string environment variable.
#include <sys/types.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -215,8 +213,9 @@
#if GTEST_HAS_STD_STRING && defined(GTEST_OS_LINUX) #if GTEST_HAS_STD_STRING && defined(GTEST_OS_LINUX)
#define GTEST_HAS_DEATH_TEST #define GTEST_HAS_DEATH_TEST
// On some platforms, <regex.h> needs someone to define size_t, and // On some platforms, <regex.h> needs someone to define size_t, and
// won't compile if being #included first. Therefore it's important // won't compile otherwise. We can #include it here as we already
// that we #include it after <sys/types.h>. // included <stdlib.h>, which is guaranteed to define size_t through
// <stddef.h>.
#include <regex.h> #include <regex.h>
#include <vector> #include <vector>
#include <fcntl.h> #include <fcntl.h>

@ -42,19 +42,7 @@
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
#include <string.h> #include <string.h>
#if defined(__APPLE__) && !defined(GTEST_NOT_MAC_FRAMEWORK_MODE)
// When using Google Test on the Mac as a framework, all the includes will be
// in the framework headers folder along with gtest.h.
// Define GTEST_NOT_MAC_FRAMEWORK_MODE if you are building Google Test on
// the Mac and are not using it as a framework.
// More info on frameworks available here:
// http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/
// Concepts/WhatAreFrameworks.html.
#include "gtest-port.h" // NOLINT
#else
#include <gtest/internal/gtest-port.h> #include <gtest/internal/gtest-port.h>
#endif // defined(__APPLE__) && !defined(GTEST_NOT_MAC_FRAMEWORK_MODE)
namespace testing { namespace testing {
namespace internal { namespace internal {

@ -158,7 +158,7 @@ def GetCommandOutput(cmd):
""" """
# Disables exception pop-ups on Windows. # Disables exception pop-ups on Windows.
os.environ['GUNIT_CATCH_EXCEPTIONS'] = '1' os.environ['GTEST_CATCH_EXCEPTIONS'] = '1'
return NormalizeOutput(GetShellCommandOutput(cmd, '')) return NormalizeOutput(GetShellCommandOutput(cmd, ''))

@ -54,7 +54,7 @@ This failure is expected, and shouldn't have a trace.
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
This failure is expected, and should have a trace. This failure is expected, and should have a trace.
gUnit trace: Google Test trace:
gtest_output_test_.cc:#: Expected trace gtest_output_test_.cc:#: Expected trace
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
@ -66,13 +66,13 @@ gtest_output_test_.cc:#: Failure
Value of: n Value of: n
Actual: 1 Actual: 1
Expected: 2 Expected: 2
gUnit trace: Google Test trace:
gtest_output_test_.cc:#: i = 1 gtest_output_test_.cc:#: i = 1
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Value of: n Value of: n
Actual: 2 Actual: 2
Expected: 1 Expected: 1
gUnit trace: Google Test trace:
gtest_output_test_.cc:#: i = 2 gtest_output_test_.cc:#: i = 2
[ FAILED ] SCOPED_TRACETest.WorksInLoop [ FAILED ] SCOPED_TRACETest.WorksInLoop
[ RUN ] SCOPED_TRACETest.WorksInSubroutine [ RUN ] SCOPED_TRACETest.WorksInSubroutine
@ -81,13 +81,13 @@ gtest_output_test_.cc:#: Failure
Value of: n Value of: n
Actual: 1 Actual: 1
Expected: 2 Expected: 2
gUnit trace: Google Test trace:
gtest_output_test_.cc:#: n = 1 gtest_output_test_.cc:#: n = 1
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Value of: n Value of: n
Actual: 2 Actual: 2
Expected: 1 Expected: 1
gUnit trace: Google Test trace:
gtest_output_test_.cc:#: n = 2 gtest_output_test_.cc:#: n = 2
[ FAILED ] SCOPED_TRACETest.WorksInSubroutine [ FAILED ] SCOPED_TRACETest.WorksInSubroutine
[ RUN ] SCOPED_TRACETest.CanBeNested [ RUN ] SCOPED_TRACETest.CanBeNested
@ -96,7 +96,7 @@ gtest_output_test_.cc:#: Failure
Value of: n Value of: n
Actual: 2 Actual: 2
Expected: 1 Expected: 1
gUnit trace: Google Test trace:
gtest_output_test_.cc:#: n = 2 gtest_output_test_.cc:#: n = 2
gtest_output_test_.cc:#: gtest_output_test_.cc:#:
[ FAILED ] SCOPED_TRACETest.CanBeNested [ FAILED ] SCOPED_TRACETest.CanBeNested
@ -105,25 +105,25 @@ gtest_output_test_.cc:#:
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
This failure is expected, and should contain trace point A. This failure is expected, and should contain trace point A.
gUnit trace: Google Test trace:
gtest_output_test_.cc:#: A gtest_output_test_.cc:#: A
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
This failure is expected, and should contain trace point A and B. This failure is expected, and should contain trace point A and B.
gUnit trace: Google Test trace:
gtest_output_test_.cc:#: B gtest_output_test_.cc:#: B
gtest_output_test_.cc:#: A gtest_output_test_.cc:#: A
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
This failure is expected, and should contain trace point A, B, and C. This failure is expected, and should contain trace point A, B, and C.
gUnit trace: Google Test trace:
gtest_output_test_.cc:#: C gtest_output_test_.cc:#: C
gtest_output_test_.cc:#: B gtest_output_test_.cc:#: B
gtest_output_test_.cc:#: A gtest_output_test_.cc:#: A
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Failed Failed
This failure is expected, and should contain trace point A, B, and D. This failure is expected, and should contain trace point A, B, and D.
gUnit trace: Google Test trace:
gtest_output_test_.cc:#: D gtest_output_test_.cc:#: D
gtest_output_test_.cc:#: B gtest_output_test_.cc:#: B
gtest_output_test_.cc:#: A gtest_output_test_.cc:#: A

@ -110,11 +110,13 @@ int g_death_test_count = 0;
TEST(BarDeathTest, ThreadSafeAndFast) { TEST(BarDeathTest, ThreadSafeAndFast) {
g_death_test_count++; g_death_test_count++;
#ifdef GTEST_HAS_DEATH_TEST
GTEST_FLAG(death_test_style) = "threadsafe"; GTEST_FLAG(death_test_style) = "threadsafe";
EXPECT_DEATH(abort(), ""); EXPECT_DEATH(abort(), "");
GTEST_FLAG(death_test_style) = "fast"; GTEST_FLAG(death_test_style) = "fast";
EXPECT_DEATH(abort(), ""); EXPECT_DEATH(abort(), "");
#endif // GTEST_HAS_DEATH_TEST
} }
// Resets the count for each test. // Resets the count for each test.

@ -80,8 +80,15 @@ def GetOutput(command):
def TestExitCodeAndOutput(command): def TestExitCodeAndOutput(command):
"""Runs the given command and verifies its exit code and output.""" """Runs the given command and verifies its exit code and output."""
# 256 corresponds to return code 0. # Verifies that 'command' exits with code 1.
if IS_WINDOWS:
# On Windows, os.system(command) returns the exit code of 'command'.
AssertEq(1, os.system(command))
else:
# On Unix-like system, os.system(command) returns 256 times the
# exit code of 'command'.
AssertEq(256, os.system(command)) AssertEq(256, os.system(command))
output = GetOutput(command) output = GetOutput(command)
Assert('InitGoogleTest' in output) Assert('InitGoogleTest' in output)

Loading…
Cancel
Save