From e0ecb7ac588e4061fe57207ff3734e465637b14d Mon Sep 17 00:00:00 2001 From: shiqian Date: Wed, 9 Jul 2008 20:58:26 +0000 Subject: Makes Google Test compile on Mac OS X and Cygwin, and adds project files for Microsoft Visual Studio. --- CHANGES | 6 + Makefile.am | 13 ++ README | 23 +++- include/gtest/internal/gtest-port.h | 5 +- msvc/gtest.sln | 85 +++++++++++++ msvc/gtest.vcproj | 207 ++++++++++++++++++++++++++++++++ msvc/gtest_color_test_.vcproj | 144 ++++++++++++++++++++++ msvc/gtest_env_var_test_.vcproj | 144 ++++++++++++++++++++++ msvc/gtest_environment_test.vcproj | 144 ++++++++++++++++++++++ msvc/gtest_main.vcproj | 165 +++++++++++++++++++++++++ msvc/gtest_output_test_.vcproj | 147 +++++++++++++++++++++++ msvc/gtest_prod_test.vcproj | 164 +++++++++++++++++++++++++ msvc/gtest_uninitialized_test_.vcproj | 144 ++++++++++++++++++++++ msvc/gtest_unittest.vcproj | 147 +++++++++++++++++++++++ test/gtest_break_on_failure_unittest.py | 8 +- test/gtest_unittest.cc | 8 +- 16 files changed, 1545 insertions(+), 9 deletions(-) create mode 100755 msvc/gtest.sln create mode 100755 msvc/gtest.vcproj create mode 100755 msvc/gtest_color_test_.vcproj create mode 100755 msvc/gtest_env_var_test_.vcproj create mode 100755 msvc/gtest_environment_test.vcproj create mode 100755 msvc/gtest_main.vcproj create mode 100755 msvc/gtest_output_test_.vcproj create mode 100755 msvc/gtest_prod_test.vcproj create mode 100755 msvc/gtest_uninitialized_test_.vcproj create mode 100755 msvc/gtest_unittest.vcproj diff --git a/CHANGES b/CHANGES index 871ef1f..eeedb2f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +Changes for 1.0.1: + + * Added project files for Visual Studio 7.1. + * Fixed issues with compiling on Mac OS X. + * Fixed issues with compiling on Cygwin. + Changes for 1.0.0: * Initial Open Source release of Google Test diff --git a/Makefile.am b/Makefile.am index 76daa30..c6e8707 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,6 +6,19 @@ EXTRA_DIST = \ CONTRIBUTORS \ scripts/gen_gtest_pred_impl.py +# MSVC project files +EXTRA_DIST += \ + msvc/gtest.sln \ + msvc/gtest.vcproj \ + msvc/gtest_color_test_.vcproj \ + msvc/gtest_env_var_test_.vcproj \ + msvc/gtest_environment_test.vcproj \ + msvc/gtest_main.vcproj \ + msvc/gtest_output_test_.vcproj \ + msvc/gtest_prod_test.vcproj \ + msvc/gtest_uninitialized_test_.vcproj \ + msvc/gtest_unittest.vcproj + # TODO(wan@google.com): integrate scripts/gen_gtest_pred_impl.py into # the build system such that a user can specify the maximum predicate # arity here and have the script automatically generate the diff --git a/README b/README index 6de66cd..2646bab 100644 --- a/README +++ b/README @@ -38,6 +38,15 @@ described below), there are further requirements: * Libtool / Libtoolize * Python version 2.4 or newer +### Windows Requirements ### + * Microsoft Visual Studio 7.1 or newer + +### Cygwin Requirements ### + * Cygwin 1.5.25-14 or newer + +### Mac OS X Requirements ### + * Mac OS X 10.4 Tiger or newer + Getting the Source ------------------ There are two primary ways of getting Google Test's source code: you can @@ -60,9 +69,10 @@ or for a release version X.Y.*'s branch: $ svn checkout http://googletest.googlecode.com/svn/branches/release-X.Y/ gtest-X.Y-svn -Next you will need to prepare the GNU Autotools build system. Enter the -target directory of the checkout command you used ('gtest-svn' or -'gtest-X.Y-svn' above) and proceed with the following commands: +Next you will need to prepare the GNU Autotools build system, if you +are using Linux, Mac OS X, or Cygwin. Enter the target directory of +the checkout command you used ('gtest-svn' or 'gtest-X.Y-svn' above) +and proceed with the following commands: $ aclocal-1.9 # Where "1.9" must match the following automake command $ libtoolize -c @@ -92,6 +102,8 @@ which contains all of the source code. Here are some examples in Linux: Building the Source ------------------- + +### Linux, Mac OS X, and Cygwin ### There are two primary options for building the source at this point: build it inside the source code tree, or in a separate directory. We recommend building in a separate directory as that tends to produce both more consistent results @@ -131,4 +143,9 @@ to uninstall the same version which you installed. $ sudo make uninstall # Must be run against the exact same build as "install" +### Windows ### +Open the gtest.sln file in the msvc/ folder using Visual Studio, and +you are ready to build Google Test the same way you build any Visual +Studio project. + Happy testing! diff --git a/include/gtest/internal/gtest-port.h b/include/gtest/internal/gtest-port.h index 4ba6d55..90298d5 100644 --- a/include/gtest/internal/gtest-port.h +++ b/include/gtest/internal/gtest-port.h @@ -66,6 +66,7 @@ // Test flag names share, in upper case. // // Macros indicating the current platform: +// GTEST_OS_CYGWIN - defined iff compiled on Cygwin. // GTEST_OS_LINUX - defined iff compiled on Linux. // GTEST_OS_MAC - defined iff compiled on Mac OS X. // GTEST_OS_WINDOWS - defined iff compiled on Windows. @@ -132,7 +133,9 @@ #define GTEST_FLAG_PREFIX_UPPER "GTEST_" // Determines the platform on which Google Test is compiled. -#ifdef _MSC_VER +#ifdef __CYGWIN__ +#define GTEST_OS_CYGWIN +#elif defined _MSC_VER // TODO(kenton@google.com): GTEST_OS_WINDOWS is currently used to mean // both "The OS is Windows" and "The compiler is MSVC". These // meanings really should be separated in order to better support diff --git a/msvc/gtest.sln b/msvc/gtest.sln new file mode 100755 index 0000000..775a40b --- /dev/null +++ b/msvc/gtest.sln @@ -0,0 +1,85 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest", "gtest.vcproj", "{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_main", "gtest_main.vcproj", "{3AF54C8A-10BF-4332-9147-F68ED9862032}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_unittest", "gtest_unittest.vcproj", "{4D9FDFB5-986A-4139-823C-F4EE0ED481A1}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_environment_test", "gtest_environment_test.vcproj", "{DF5FA93D-DC03-41A6-A18C-079198633450}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_prod_test", "gtest_prod_test.vcproj", "{24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_color_test_", "gtest_color_test_.vcproj", "{ABC5A7E8-072C-4A2D-B186-19EA5394B9C6}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_env_var_test_", "gtest_env_var_test_.vcproj", "{569C6F70-F41C-47F3-A622-8A88DC43D452}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_output_test_", "gtest_output_test_.vcproj", "{A4903F73-ED6C-4972-863E-F7355EB0145E}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_uninitialized_test_", "gtest_uninitialized_test_.vcproj", "{42B8A077-E162-4540-A688-246296ACAC1D}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug.ActiveCfg = Debug|Win32 + {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug.Build.0 = Debug|Win32 + {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release.ActiveCfg = Release|Win32 + {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release.Build.0 = Release|Win32 + {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug.ActiveCfg = Debug|Win32 + {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug.Build.0 = Debug|Win32 + {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release.ActiveCfg = Release|Win32 + {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release.Build.0 = Release|Win32 + {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Debug.ActiveCfg = Debug|Win32 + {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Debug.Build.0 = Debug|Win32 + {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Release.ActiveCfg = Release|Win32 + {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Release.Build.0 = Release|Win32 + {DF5FA93D-DC03-41A6-A18C-079198633450}.Debug.ActiveCfg = Debug|Win32 + {DF5FA93D-DC03-41A6-A18C-079198633450}.Debug.Build.0 = Debug|Win32 + {DF5FA93D-DC03-41A6-A18C-079198633450}.Release.ActiveCfg = Release|Win32 + {DF5FA93D-DC03-41A6-A18C-079198633450}.Release.Build.0 = Release|Win32 + {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Debug.ActiveCfg = Debug|Win32 + {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Debug.Build.0 = Debug|Win32 + {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Release.ActiveCfg = Release|Win32 + {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Release.Build.0 = Release|Win32 + {ABC5A7E8-072C-4A2D-B186-19EA5394B9C6}.Debug.ActiveCfg = Debug|Win32 + {ABC5A7E8-072C-4A2D-B186-19EA5394B9C6}.Debug.Build.0 = Debug|Win32 + {ABC5A7E8-072C-4A2D-B186-19EA5394B9C6}.Release.ActiveCfg = Release|Win32 + {ABC5A7E8-072C-4A2D-B186-19EA5394B9C6}.Release.Build.0 = Release|Win32 + {569C6F70-F41C-47F3-A622-8A88DC43D452}.Debug.ActiveCfg = Debug|Win32 + {569C6F70-F41C-47F3-A622-8A88DC43D452}.Debug.Build.0 = Debug|Win32 + {569C6F70-F41C-47F3-A622-8A88DC43D452}.Release.ActiveCfg = Release|Win32 + {569C6F70-F41C-47F3-A622-8A88DC43D452}.Release.Build.0 = Release|Win32 + {A4903F73-ED6C-4972-863E-F7355EB0145E}.Debug.ActiveCfg = Debug|Win32 + {A4903F73-ED6C-4972-863E-F7355EB0145E}.Debug.Build.0 = Debug|Win32 + {A4903F73-ED6C-4972-863E-F7355EB0145E}.Release.ActiveCfg = Release|Win32 + {A4903F73-ED6C-4972-863E-F7355EB0145E}.Release.Build.0 = Release|Win32 + {42B8A077-E162-4540-A688-246296ACAC1D}.Debug.ActiveCfg = Debug|Win32 + {42B8A077-E162-4540-A688-246296ACAC1D}.Debug.Build.0 = Debug|Win32 + {42B8A077-E162-4540-A688-246296ACAC1D}.Release.ActiveCfg = Release|Win32 + {42B8A077-E162-4540-A688-246296ACAC1D}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/msvc/gtest.vcproj b/msvc/gtest.vcproj new file mode 100755 index 0000000..3f2a5a6 --- /dev/null +++ b/msvc/gtest.vcproj @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/msvc/gtest_color_test_.vcproj b/msvc/gtest_color_test_.vcproj new file mode 100755 index 0000000..f879c2f --- /dev/null +++ b/msvc/gtest_color_test_.vcproj @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/msvc/gtest_env_var_test_.vcproj b/msvc/gtest_env_var_test_.vcproj new file mode 100755 index 0000000..b51f4d8 --- /dev/null +++ b/msvc/gtest_env_var_test_.vcproj @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/msvc/gtest_environment_test.vcproj b/msvc/gtest_environment_test.vcproj new file mode 100755 index 0000000..7cdd276 --- /dev/null +++ b/msvc/gtest_environment_test.vcproj @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/msvc/gtest_main.vcproj b/msvc/gtest_main.vcproj new file mode 100755 index 0000000..eeaa236 --- /dev/null +++ b/msvc/gtest_main.vcproj @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/msvc/gtest_output_test_.vcproj b/msvc/gtest_output_test_.vcproj new file mode 100755 index 0000000..2d7808a --- /dev/null +++ b/msvc/gtest_output_test_.vcproj @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/msvc/gtest_prod_test.vcproj b/msvc/gtest_prod_test.vcproj new file mode 100755 index 0000000..b358841 --- /dev/null +++ b/msvc/gtest_prod_test.vcproj @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/msvc/gtest_uninitialized_test_.vcproj b/msvc/gtest_uninitialized_test_.vcproj new file mode 100755 index 0000000..d7d158f --- /dev/null +++ b/msvc/gtest_uninitialized_test_.vcproj @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/msvc/gtest_unittest.vcproj b/msvc/gtest_unittest.vcproj new file mode 100755 index 0000000..609aa9a --- /dev/null +++ b/msvc/gtest_unittest.vcproj @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/gtest_break_on_failure_unittest.py b/test/gtest_break_on_failure_unittest.py index 1b18339..674ef11 100755 --- a/test/gtest_break_on_failure_unittest.py +++ b/test/gtest_break_on_failure_unittest.py @@ -74,10 +74,14 @@ def SetEnvVar(env_var, value): def Run(command): - """Runs a command; returns 1 if it has a segmentation fault, or 0 otherwise. + """Runs a command; returns 1 if it was killed by a signal, or 0 otherwise. """ - return os.system(command) == signal.SIGSEGV + exit_code = os.system(command) + # On Unix-like systems, the lowest 8 bits of the exit code is the + # signal number that killed the process (or 0 if it wasn't killed by + # a signal). + return (exit_code & 255) != 0 # The unit test. diff --git a/test/gtest_unittest.cc b/test/gtest_unittest.cc index 9a64a13..02799a4 100644 --- a/test/gtest_unittest.cc +++ b/test/gtest_unittest.cc @@ -157,10 +157,12 @@ TEST(ToUtf8StringTest, CanEncode12To16Bits) { EXPECT_STREQ("\xEC\x9D\x8D", ToUtf8String(L'\xC74D').c_str()); } -#if !defined(GTEST_OS_WINDOWS) && !defined(__SYMBIAN32__) +#if !defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_CYGWIN) && \ + !defined(__SYMBIAN32__) // Tests in this group require a wchar_t to hold > 16 bits, and thus -// are skipped on Windows and Symbian, where a wchar_t is 16-bit wide. +// are skipped on Windows, Cygwin, and Symbian, where a wchar_t is +// 16-bit wide. // Tests that Unicode code-points that have 17 to 21 bits are encoded // as 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx. @@ -178,7 +180,7 @@ TEST(ToUtf8StringTest, CanEncodeInvalidCodePoint) { ToUtf8String(L'\x1234ABCD').c_str()); } -#endif // Windows or Symbian +#endif // Windows, Cygwin, or Symbian // Tests the List template class. -- cgit v0.12