Fixes broken gtest_unittest on Cygwin and cleans it up (by Vlad Losev); fixes the wrong usage of os.environ.clear() in gtest_output_test.py (by Vlad Losev); fixes the logic for detecting Symbian (by Zhanyong Wan); moves TestProperty for event listener (by Vlad Losev).

This commit is contained in:
zhanyong.wan 2009-06-19 00:24:28 +00:00
parent 532dc2de35
commit ae3247986b
5 changed files with 56 additions and 57 deletions

View File

@ -346,6 +346,44 @@ class Test {
GTEST_DISALLOW_COPY_AND_ASSIGN_(Test); GTEST_DISALLOW_COPY_AND_ASSIGN_(Test);
}; };
namespace internal {
// A copyable object representing a user specified test property which can be
// output as a key/value string pair.
//
// Don't inherit from TestProperty as its destructor is not virtual.
class TestProperty {
public:
// C'tor. TestProperty does NOT have a default constructor.
// Always use this constructor (with parameters) to create a
// TestProperty object.
TestProperty(const char* key, const char* value) :
key_(key), value_(value) {
}
// Gets the user supplied key.
const char* key() const {
return key_.c_str();
}
// Gets the user supplied value.
const char* value() const {
return value_.c_str();
}
// Sets a new value, overriding the one supplied in the constructor.
void SetValue(const char* new_value) {
value_ = new_value;
}
private:
// The key supplied by the user.
String key_;
// The value supplied by the user.
String value_;
};
} // namespace internal
// A TestInfo object stores the following information about a test: // A TestInfo object stores the following information about a test:
// //

View File

@ -177,7 +177,7 @@
// Determines the platform on which Google Test is compiled. // Determines the platform on which Google Test is compiled.
#ifdef __CYGWIN__ #ifdef __CYGWIN__
#define GTEST_OS_CYGWIN 1 #define GTEST_OS_CYGWIN 1
#elif __SYMBIAN32__ #elif defined __SYMBIAN32__
#define GTEST_OS_SYMBIAN 1 #define GTEST_OS_SYMBIAN 1
#elif defined _WIN32 #elif defined _WIN32
#define GTEST_OS_WINDOWS 1 #define GTEST_OS_WINDOWS 1

View File

@ -450,41 +450,6 @@ static void Delete(T * x) {
delete x; delete x;
} }
// A copyable object representing a user specified test property which can be
// output as a key/value string pair.
//
// Don't inherit from TestProperty as its destructor is not virtual.
class TestProperty {
public:
// C'tor. TestProperty does NOT have a default constructor.
// Always use this constructor (with parameters) to create a
// TestProperty object.
TestProperty(const char* key, const char* value) :
key_(key), value_(value) {
}
// Gets the user supplied key.
const char* key() const {
return key_.c_str();
}
// Gets the user supplied value.
const char* value() const {
return value_.c_str();
}
// Sets a new value, overriding the one supplied in the constructor.
void SetValue(const char* new_value) {
value_ = new_value;
}
private:
// The key supplied by the user.
String key_;
// The value supplied by the user.
String value_;
};
// A predicate that checks the key of a TestProperty against a known key. // A predicate that checks the key of a TestProperty against a known key.
// //
// TestPropertyKeyIs is copyable. // TestPropertyKeyIs is copyable.

View File

@ -185,7 +185,11 @@ def IterShellCommandOutput(env_cmd, stdin_string=None):
old_env_vars = dict(os.environ) old_env_vars = dict(os.environ)
os.environ.update(env_cmd[0]) os.environ.update(env_cmd[0])
stdin_file, stdout_file = os.popen2(env_cmd[1], 'b') stdin_file, stdout_file = os.popen2(env_cmd[1], 'b')
os.environ.clear() # Changes made by os.environ.clear are not inheritable by child processes
# until Python 2.6. To produce inheritable changes we have to delete
# environment items with the del statement.
for key in os.environ.keys():
del os.environ[key]
os.environ.update(old_env_vars) os.environ.update(old_env_vars)
# If the caller didn't specify a string for STDIN, gets it from the # If the caller didn't specify a string for STDIN, gets it from the

View File

@ -64,6 +64,7 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_ #undef GTEST_IMPLEMENTATION_
#include <limits.h> // For INT_MAX.
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
@ -71,15 +72,6 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
#include <pthread.h> #include <pthread.h>
#endif // GTEST_HAS_PTHREAD #endif // GTEST_HAS_PTHREAD
#if GTEST_OS_LINUX
#include <string.h>
#include <signal.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string>
#include <vector>
#endif // GTEST_OS_LINUX
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#include <map> #include <map>
#endif #endif
@ -784,7 +776,7 @@ TEST(StringTest, AnsiAndUtf16ConvertBasic) {
EXPECT_STREQ("str", ansi); EXPECT_STREQ("str", ansi);
delete [] ansi; delete [] ansi;
const WCHAR* utf16 = String::AnsiToUtf16("str"); const WCHAR* utf16 = String::AnsiToUtf16("str");
EXPECT_TRUE(wcsncmp(L"str", utf16, 3) == 0); EXPECT_EQ(0, wcsncmp(L"str", utf16, 3));
delete [] utf16; delete [] utf16;
} }
@ -793,7 +785,7 @@ TEST(StringTest, AnsiAndUtf16ConvertPathChars) {
EXPECT_STREQ(".:\\ \"*?", ansi); EXPECT_STREQ(".:\\ \"*?", ansi);
delete [] ansi; delete [] ansi;
const WCHAR* utf16 = String::AnsiToUtf16(".:\\ \"*?"); const WCHAR* utf16 = String::AnsiToUtf16(".:\\ \"*?");
EXPECT_TRUE(wcsncmp(L".:\\ \"*?", utf16, 3) == 0); EXPECT_EQ(0, wcsncmp(L".:\\ \"*?", utf16, 3));
delete [] utf16; delete [] utf16;
} }
#endif // _WIN32_WCE #endif // _WIN32_WCE
@ -3398,13 +3390,13 @@ TEST(AssertionSyntaxTest, BasicAssertionsBehavesLikeSingleStatement) {
if (true) if (true)
EXPECT_FALSE(false); EXPECT_FALSE(false);
else else
; ; // NOLINT
if (false) if (false)
ASSERT_LT(1, 3); ASSERT_LT(1, 3);
if (false) if (false)
; ; // NOLINT
else else
EXPECT_GT(3, 2) << ""; EXPECT_GT(3, 2) << "";
} }
@ -3431,7 +3423,7 @@ TEST(AssertionSyntaxTest, ExceptionAssertionsBehavesLikeSingleStatement) {
if (true) if (true)
EXPECT_THROW(ThrowAnInteger(), int); EXPECT_THROW(ThrowAnInteger(), int);
else else
; ; // NOLINT
if (false) if (false)
EXPECT_NO_THROW(ThrowAnInteger()); EXPECT_NO_THROW(ThrowAnInteger());
@ -3439,7 +3431,7 @@ TEST(AssertionSyntaxTest, ExceptionAssertionsBehavesLikeSingleStatement) {
if (true) if (true)
EXPECT_NO_THROW(ThrowNothing()); EXPECT_NO_THROW(ThrowNothing());
else else
; ; // NOLINT
if (false) if (false)
EXPECT_ANY_THROW(ThrowNothing()); EXPECT_ANY_THROW(ThrowNothing());
@ -3447,7 +3439,7 @@ TEST(AssertionSyntaxTest, ExceptionAssertionsBehavesLikeSingleStatement) {
if (true) if (true)
EXPECT_ANY_THROW(ThrowAnInteger()); EXPECT_ANY_THROW(ThrowAnInteger());
else else
; ; // NOLINT
} }
#endif // GTEST_HAS_EXCEPTIONS #endif // GTEST_HAS_EXCEPTIONS
@ -3456,20 +3448,20 @@ TEST(AssertionSyntaxTest, NoFatalFailureAssertionsBehavesLikeSingleStatement) {
EXPECT_NO_FATAL_FAILURE(FAIL()) << "This should never be executed. " EXPECT_NO_FATAL_FAILURE(FAIL()) << "This should never be executed. "
<< "It's a compilation test only."; << "It's a compilation test only.";
else else
; ; // NOLINT
if (false) if (false)
ASSERT_NO_FATAL_FAILURE(FAIL()) << ""; ASSERT_NO_FATAL_FAILURE(FAIL()) << "";
else else
; ; // NOLINT
if (true) if (true)
EXPECT_NO_FATAL_FAILURE(SUCCEED()); EXPECT_NO_FATAL_FAILURE(SUCCEED());
else else
; ; // NOLINT
if (false) if (false)
; ; // NOLINT
else else
ASSERT_NO_FATAL_FAILURE(SUCCEED()); ASSERT_NO_FATAL_FAILURE(SUCCEED());
} }