Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
88e97c82
Commit
88e97c82
authored
Dec 16, 2009
by
zhanyong.wan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removes uses of GTEST_HAS_STD_STRING.
parent
075b76bb
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
90 additions
and
149 deletions
+90
-149
gtest.h
include/gtest/gtest.h
+10
-19
gtest-internal.h
include/gtest/internal/gtest-internal.h
+0
-2
gtest-port.h
include/gtest/internal/gtest-port.h
+12
-54
gtest-string.h
include/gtest/internal/gtest-string.h
+0
-4
run_tests.py
run_tests.py
+8
-1
SConscript.common
scons/SConscript.common
+0
-3
SConstruct
scons/SConstruct
+5
-1
SConstruct.common
scons/SConstruct.common
+15
-8
gtest.cc
src/gtest.cc
+0
-14
gtest-death-test_test.cc
test/gtest-death-test_test.cc
+0
-2
gtest-message_test.cc
test/gtest-message_test.cc
+0
-4
gtest-port_test.cc
test/gtest-port_test.cc
+0
-2
gtest_output_test.py
test/gtest_output_test.py
+14
-14
gtest_unittest.cc
test/gtest_unittest.cc
+0
-18
run_tests_util.py
test/run_tests_util.py
+26
-3
No files found.
include/gtest/gtest.h
View file @
88e97c82
...
...
@@ -62,24 +62,19 @@
#include <gtest/gtest-typed-test.h>
// Depending on the platform, different string classes are available.
// On Windows, ::std::string compiles only when exceptions are
// enabled. On Linux, in addition to ::std::string, Google also makes
// use of class ::string, which has the same interface as
// ::std::string, but has a different implementation.
//
// The user can tell us whether ::std::string is available in his
// environment by defining the macro GTEST_HAS_STD_STRING to either 1
// or 0 on the compiler command line. He can also define
// GTEST_HAS_GLOBAL_STRING to 1 to indicate that ::string is available
// AND is a distinct type to ::std::string, or define it to 0 to
// indicate otherwise.
// On Linux, in addition to ::std::string, Google also makes use of
// class ::string, which has the same interface as ::std::string, but
// has a different implementation.
//
// The user can define GTEST_HAS_GLOBAL_STRING to 1 to indicate that
// ::string is available AND is a distinct type to ::std::string, or
// define it to 0 to indicate otherwise.
//
// If the user's ::std::string and ::string are the same class due to
// aliasing, he should define GTEST_HAS_STD_STRING to 1 and
// GTEST_HAS_GLOBAL_STRING to 0.
// aliasing, he should define GTEST_HAS_GLOBAL_STRING to 0.
//
// If the user doesn't define GTEST_HAS_
STD_STRING and/or
//
GTEST_HAS_GLOBAL_STRING, they are defined
heuristically.
// If the user doesn't define GTEST_HAS_
GLOBAL_STRING, it is defined
// heuristically.
namespace
testing
{
...
...
@@ -1210,11 +1205,9 @@ void InitGoogleTest(int* argc, wchar_t** argv);
namespace
internal
{
// These overloaded versions handle ::std::string and ::std::wstring.
#if GTEST_HAS_STD_STRING
inline
String
FormatForFailureMessage
(
const
::
std
::
string
&
str
)
{
return
(
Message
()
<<
'"'
<<
str
<<
'"'
).
GetString
();
}
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_STD_WSTRING
inline
String
FormatForFailureMessage
(
const
::
std
::
wstring
&
wstr
)
{
...
...
@@ -1464,14 +1457,12 @@ AssertionResult IsNotSubstring(
AssertionResult
IsNotSubstring
(
const
char
*
needle_expr
,
const
char
*
haystack_expr
,
const
wchar_t
*
needle
,
const
wchar_t
*
haystack
);
#if GTEST_HAS_STD_STRING
AssertionResult
IsSubstring
(
const
char
*
needle_expr
,
const
char
*
haystack_expr
,
const
::
std
::
string
&
needle
,
const
::
std
::
string
&
haystack
);
AssertionResult
IsNotSubstring
(
const
char
*
needle_expr
,
const
char
*
haystack_expr
,
const
::
std
::
string
&
needle
,
const
::
std
::
string
&
haystack
);
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_STD_WSTRING
AssertionResult
IsSubstring
(
...
...
include/gtest/internal/gtest-internal.h
View file @
88e97c82
...
...
@@ -259,9 +259,7 @@ inline String FormatForComparisonFailureMessage(\
return operand1_printer(str);\
}
#if GTEST_HAS_STD_STRING
GTEST_FORMAT_IMPL_
(
::
std
::
string
,
String
::
ShowCStringQuoted
)
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_STD_WSTRING
GTEST_FORMAT_IMPL_
(
::
std
::
wstring
,
String
::
ShowWideCStringQuoted
)
#endif // GTEST_HAS_STD_WSTRING
...
...
include/gtest/internal/gtest-port.h
View file @
88e97c82
...
...
@@ -52,9 +52,6 @@
// is/isn't available.
// GTEST_HAS_RTTI - Define it to 1/0 to indicate that RTTI is/isn't
// enabled.
// GTEST_HAS_STD_STRING - Define it to 1/0 to indicate that
// std::string does/doesn't work (Google Test can
// be used where std::string is unavailable).
// GTEST_HAS_STD_WSTRING - Define it to 1/0 to indicate that
// std::wstring does/doesn't work (Google Test can
// be used where std::wstring is unavailable).
...
...
@@ -261,23 +258,14 @@
#endif // defined(__GNUC__) && __EXCEPTIONS
#endif // defined(_MSC_VER) || defined(__BORLANDC__)
// Determines whether ::std::string and ::string are available.
#ifndef GTEST_HAS_STD_STRING
// The user didn't tell us whether ::std::string is available, so we
// need to figure it out. The only environment that we know
// ::std::string is not available is MSVC 7.1 or lower with exceptions
// disabled.
#if defined(_MSC_VER) && (_MSC_VER < 1400) && !GTEST_HAS_EXCEPTIONS
#if !GTEST_ALLOW_VC71_WITHOUT_EXCEPTIONS_
#error "When compiling gtest using MSVC 7.1, exceptions must be enabled."
#error "Otherwise std::string and std::vector don't compile."
#endif
#define GTEST_HAS_STD_STRING 0
#else
#if !defined(GTEST_HAS_STD_STRING)
// Even though we don't use this macro any longer, we keep it in case
// some clients still depend on it.
#define GTEST_HAS_STD_STRING 1
#endif
#endif // GTEST_HAS_STD_STRING
#elif !GTEST_HAS_STD_STRING
// The user told us that ::std::string isn't available.
#error "Google Test cannot be used where ::std::string isn't available."
#endif // !defined(GTEST_HAS_STD_STRING)
#ifndef GTEST_HAS_GLOBAL_STRING
// The user didn't tell us whether ::string is available, so we need
...
...
@@ -293,14 +281,10 @@
// TODO(wan@google.com): uses autoconf to detect whether ::std::wstring
// is available.
#if GTEST_OS_CYGWIN || GTEST_OS_SOLARIS
// Cygwin 1.5 and below doesn't support ::std::wstring.
// Cygwin 1.7 might add wstring support; this should be updated when clear.
// Solaris' libc++ doesn't support it either.
#define GTEST_HAS_STD_WSTRING 0
#else
#define GTEST_HAS_STD_WSTRING GTEST_HAS_STD_STRING
#endif // GTEST_OS_CYGWIN || GTEST_OS_SOLARIS
#define GTEST_HAS_STD_WSTRING (!(GTEST_OS_CYGWIN || GTEST_OS_SOLARIS))
#endif // GTEST_HAS_STD_WSTRING
...
...
@@ -311,17 +295,8 @@
(GTEST_HAS_STD_WSTRING && GTEST_HAS_GLOBAL_STRING)
#endif // GTEST_HAS_GLOBAL_WSTRING
#if GTEST_HAS_STD_STRING || GTEST_HAS_GLOBAL_STRING || \
GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING
#include <string> // NOLINT
#endif // GTEST_HAS_STD_STRING || GTEST_HAS_GLOBAL_STRING ||
// GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING
#if GTEST_HAS_STD_STRING
#include <sstream> // NOLINT
#else
#include <strstream> // NOLINT
#endif // GTEST_HAS_STD_STRING
// Determines whether RTTI is available.
#ifndef GTEST_HAS_RTTI
...
...
@@ -457,15 +432,10 @@
#endif // GTEST_HAS_CLONE
// Determines whether to support death tests.
// Google Test does not support death tests for VC 7.1 and earlier for
// these reasons:
// 1. std::vector does not build in VC 7.1 when exceptions are disabled.
// 2. std::string does not build in VC 7.1 when exceptions are disabled
// (this is covered by GTEST_HAS_STD_STRING guard).
// 3. abort() in a VC 7.1 application compiled as GUI in debug config
// pops up a dialog window that cannot be suppressed programmatically.
#if GTEST_HAS_STD_STRING && \
(GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_CYGWIN || \
// Google Test does not support death tests for VC 7.1 and earlier as
// abort() in a VC 7.1 application compiled as GUI in debug config
// pops up a dialog window that cannot be suppressed programmatically.
#if (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_CYGWIN || \
(GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || GTEST_OS_WINDOWS_MINGW)
#define GTEST_HAS_DEATH_TEST 1
#include <vector> // NOLINT
...
...
@@ -572,15 +542,7 @@ namespace internal {
class
String
;
// std::strstream is deprecated. However, we have to use it on
// Windows as std::stringstream won't compile on Windows when
// exceptions are disabled. We use std::stringstream on other
// platforms to avoid compiler warnings there.
#if GTEST_HAS_STD_STRING
typedef
::
std
::
stringstream
StrStream
;
#else
typedef
::
std
::
strstream
StrStream
;
#endif // GTEST_HAS_STD_STRING
// A helper for suppressing warnings on constant condition. It just
// returns 'condition'.
...
...
@@ -629,9 +591,7 @@ class scoped_ptr {
class
RE
{
public
:
// Constructs an RE from a string.
#if GTEST_HAS_STD_STRING
RE
(
const
::
std
::
string
&
regex
)
{
Init
(
regex
.
c_str
());
}
// NOLINT
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_GLOBAL_STRING
RE
(
const
::
string
&
regex
)
{
Init
(
regex
.
c_str
());
}
// NOLINT
...
...
@@ -650,14 +610,12 @@ class RE {
//
// TODO(wan@google.com): make FullMatch() and PartialMatch() work
// when str contains NUL characters.
#if GTEST_HAS_STD_STRING
static
bool
FullMatch
(
const
::
std
::
string
&
str
,
const
RE
&
re
)
{
return
FullMatch
(
str
.
c_str
(),
re
);
}
static
bool
PartialMatch
(
const
::
std
::
string
&
str
,
const
RE
&
re
)
{
return
PartialMatch
(
str
.
c_str
(),
re
);
}
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_GLOBAL_STRING
static
bool
FullMatch
(
const
::
string
&
str
,
const
RE
&
re
)
{
...
...
include/gtest/internal/gtest-string.h
View file @
88e97c82
...
...
@@ -44,9 +44,7 @@
#include <string.h>
#include <gtest/internal/gtest-port.h>
#if GTEST_HAS_GLOBAL_STRING || GTEST_HAS_STD_STRING
#include <string>
#endif // GTEST_HAS_GLOBAL_STRING || GTEST_HAS_STD_STRING
namespace
testing
{
namespace
internal
{
...
...
@@ -221,13 +219,11 @@ class String {
// Converting a ::std::string or ::string containing an embedded NUL
// character to a String will result in the prefix up to the first
// NUL character.
#if GTEST_HAS_STD_STRING
String
(
const
::
std
::
string
&
str
)
{
ConstructNonNull
(
str
.
c_str
(),
str
.
length
());
}
operator
::
std
::
string
()
const
{
return
::
std
::
string
(
c_str
(),
length
());
}
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_GLOBAL_STRING
String
(
const
::
string
&
str
)
{
...
...
run_tests.py
View file @
88e97c82
...
...
@@ -39,6 +39,12 @@ import sys
SCRIPT_DIR
=
os
.
path
.
dirname
(
__file__
)
or
'.'
# Some Python tests don't work in all configurations.
PYTHON_TESTS_TO_SKIP
=
(
(
'win-dbg'
,
'gtest_throw_on_failure_test.py'
),
(
'win-opt'
,
'gtest_throw_on_failure_test.py'
),
)
sys
.
path
.
append
(
os
.
path
.
join
(
SCRIPT_DIR
,
'test'
))
import
run_tests_util
...
...
@@ -50,7 +56,8 @@ def _Main():
test_runner
=
run_tests_util
.
TestRunner
(
script_dir
=
SCRIPT_DIR
)
tests
=
test_runner
.
GetTestsToRun
(
args
,
options
.
configurations
,
options
.
built_configurations
)
options
.
built_configurations
,
python_tests_to_skip
=
PYTHON_TESTS_TO_SKIP
)
if
not
tests
:
sys
.
exit
(
1
)
# Incorrect parameters given, abort execution.
...
...
scons/SConscript.common
View file @
88e97c82
...
...
@@ -88,9 +88,6 @@ class EnvCreator:
if env['PLATFORM'] == 'win32':
env.Append(CCFLAGS=['/EHsc'])
env.Append(CPPDEFINES='_HAS_EXCEPTIONS=1')
# Undoes the _TYPEINFO_ hack, which is unnecessary and only creates
# trouble when exceptions are enabled.
cls._Remove(env, 'CPPDEFINES', '_TYPEINFO_')
cls._Remove(env, 'CPPDEFINES', '_HAS_EXCEPTIONS=0')
else:
env.Append(CCFLAGS='-fexceptions')
...
...
scons/SConstruct
View file @
88e97c82
...
...
@@ -50,8 +50,12 @@ sconstruct_helper.Initialize(build_root_path='..',
win_base
=
sconstruct_helper
.
MakeWinBaseEnvironment
()
# We don't support VC 7.1 with exceptions disabled, so we always
# enable exceptions for VC 7.1. For newer versions of VC, we still
# compile with exceptions disabled by default, as that's a more common
# setting for our users.
if
win_base
.
get
(
'MSVS_VERSION'
,
None
)
==
'7.1'
:
sconstruct_helper
.
AllowVc71StlWithout
Exceptions
(
win_base
)
sconstruct_helper
.
Enable
Exceptions
(
win_base
)
sconstruct_helper
.
MakeWinDebugEnvironment
(
win_base
,
'win-dbg'
)
sconstruct_helper
.
MakeWinOptimizedEnvironment
(
win_base
,
'win-opt'
)
...
...
scons/SConstruct.common
View file @
88e97c82
...
...
@@ -45,6 +45,13 @@ class SConstructHelper:
# A dictionary to look up an environment by its name.
self.env_dict = {}
def _Remove(self, env, attribute, value):
"""Removes the given attribute value from the environment."""
attribute_values = env[attribute]
if value in attribute_values:
attribute_values.remove(value)
def Initialize(self, build_root_path, support_multiple_win_builds=False):
test_env = Environment()
platform = test_env['PLATFORM']
...
...
@@ -83,13 +90,14 @@ class SConstructHelper:
# Enable scons -h
Help(vars.GenerateHelpText(self.env_base))
def AllowVc71StlWithoutExceptions(self, env):
env.Append(
CPPDEFINES = [# needed for using some parts of STL with exception
# disabled. The scoop is given here, with comments
# from P.J. Plauger at
# http://groups.google.com/group/microsoft.public.vc.stl/browse_thread/thread/5e719833c6bdb177?q=_HAS_EXCEPTIONS+using+namespace+std&pli=1
'_TYPEINFO_'])
def EnableExceptions(self, env):
if env['PLATFORM'] == 'win32':
env.Append(CCFLAGS=['/EHsc'])
env.Append(CPPDEFINES='_HAS_EXCEPTIONS=1')
self._Remove(env, 'CPPDEFINES', '_HAS_EXCEPTIONS=0')
else:
env.Append(CCFLAGS='-fexceptions')
self._Remove(env, 'CCFLAGS', '-fno-exceptions')
def MakeWinBaseEnvironment(self):
win_base = self.env_base.Clone(
...
...
@@ -117,7 +125,6 @@ class SConstructHelper:
'STRICT',
'WIN32_LEAN_AND_MEAN',
'_HAS_EXCEPTIONS=0',
'GTEST_ALLOW_VC71_WITHOUT_EXCEPTIONS_=1',
],
LIBPATH=['#/$MAIN_DIR/lib'],
LINKFLAGS=['-MACHINE:x86', # Enable safe SEH (not supp. on x64)
...
...
src/gtest.cc
View file @
88e97c82
...
...
@@ -1316,7 +1316,6 @@ AssertionResult IsNotSubstring(
return
IsSubstringImpl
(
false
,
needle_expr
,
haystack_expr
,
needle
,
haystack
);
}
#if GTEST_HAS_STD_STRING
AssertionResult
IsSubstring
(
const
char
*
needle_expr
,
const
char
*
haystack_expr
,
const
::
std
::
string
&
needle
,
const
::
std
::
string
&
haystack
)
{
...
...
@@ -1328,7 +1327,6 @@ AssertionResult IsNotSubstring(
const
::
std
::
string
&
needle
,
const
::
std
::
string
&
haystack
)
{
return
IsSubstringImpl
(
false
,
needle_expr
,
haystack_expr
,
needle
,
haystack
);
}
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_STD_WSTRING
AssertionResult
IsSubstring
(
...
...
@@ -1748,14 +1746,9 @@ String String::Format(const char * format, ...) {
// Converts the buffer in a StrStream to a String, converting NUL
// bytes to "\\0" along the way.
String
StrStreamToString
(
StrStream
*
ss
)
{
#if GTEST_HAS_STD_STRING
const
::
std
::
string
&
str
=
ss
->
str
();
const
char
*
const
start
=
str
.
c_str
();
const
char
*
const
end
=
start
+
str
.
length
();
#else
const
char
*
const
start
=
ss
->
str
();
const
char
*
const
end
=
start
+
ss
->
pcount
();
#endif // GTEST_HAS_STD_STRING
// We need to use a helper StrStream to do this transformation
// because String doesn't support push_back().
...
...
@@ -1768,14 +1761,7 @@ String StrStreamToString(StrStream* ss) {
}
}
#if GTEST_HAS_STD_STRING
return
String
(
helper
.
str
().
c_str
());
#else
const
String
str
(
helper
.
str
(),
helper
.
pcount
());
helper
.
freeze
(
false
);
ss
->
freeze
(
false
);
return
str
;
#endif // GTEST_HAS_STD_STRING
}
// Appends the user-supplied message to the Google-Test-generated message.
...
...
test/gtest-death-test_test.cc
View file @
88e97c82
...
...
@@ -449,10 +449,8 @@ TEST_F(TestForDeathTest, AcceptsAnythingConvertibleToRE) {
EXPECT_DEATH
(
GlobalFunction
(),
regex_str
);
#endif // GTEST_HAS_GLOBAL_STRING
#if GTEST_HAS_STD_STRING
const
::
std
::
string
regex_std_str
(
regex_c_str
);
EXPECT_DEATH
(
GlobalFunction
(),
regex_std_str
);
#endif // GTEST_HAS_STD_STRING
}
// Tests that a non-void function can be used in a death test.
...
...
test/gtest-message_test.cc
View file @
88e97c82
...
...
@@ -92,8 +92,6 @@ TEST(MessageTest, StreamsNullCString) {
EXPECT_STREQ
(
"(null)"
,
ToCString
(
Message
()
<<
p
));
}
#if GTEST_HAS_STD_STRING
// Tests streaming std::string.
//
// As std::string has problem in MSVC when exception is disabled, we only
...
...
@@ -113,8 +111,6 @@ TEST(MessageTest, StreamsStringWithEmbeddedNUL) {
ToCString
(
Message
()
<<
string_with_nul
));
}
#endif // GTEST_HAS_STD_STRING
// Tests streaming a NUL char.
TEST
(
MessageTest
,
StreamsNULChar
)
{
EXPECT_STREQ
(
"
\\
0"
,
ToCString
(
Message
()
<<
'\0'
));
...
...
test/gtest-port_test.cc
View file @
88e97c82
...
...
@@ -177,9 +177,7 @@ class RETest : public ::testing::Test {};
// Defines StringTypes as the list of all string types that class RE
// supports.
typedef
testing
::
Types
<
#if GTEST_HAS_STD_STRING
::
std
::
string
,
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_GLOBAL_STRING
::
string
,
#endif // GTEST_HAS_GLOBAL_STRING
...
...
test/gtest_output_test.py
View file @
88e97c82
...
...
@@ -126,15 +126,15 @@ def RemoveTime(output):
def
RemoveTestCounts
(
output
):
"""Removes test counts from a Google Test program's output."""
output
=
re
.
sub
(
r'\d+ tests, listed below'
,
output
=
re
.
sub
(
r'\d+ tests
?
, listed below'
,
'? tests, listed below'
,
output
)
output
=
re
.
sub
(
r'\d+ FAILED TESTS'
,
'? FAILED TESTS'
,
output
)
output
=
re
.
sub
(
r'\d+ tests
from \d+ test cases
'
,
output
=
re
.
sub
(
r'\d+ tests
? from \d+ test cases?
'
,
'? tests from ? test cases'
,
output
)
output
=
re
.
sub
(
r'\d+ tests from ([a-zA-Z_])'
,
output
=
re
.
sub
(
r'\d+ tests
?
from ([a-zA-Z_])'
,
r'? tests from \1'
,
output
)
return
re
.
sub
(
r'\d+ tests\.'
,
'? tests.'
,
output
)
return
re
.
sub
(
r'\d+ tests
?
\.'
,
'? tests.'
,
output
)
def
RemoveMatchingTests
(
test_output
,
pattern
):
...
...
@@ -268,16 +268,16 @@ class GTestOutputTest(gtest_test_utils.TestCase):
normalized_actual
=
RemoveTestCounts
(
output
)
normalized_golden
=
RemoveTestCounts
(
self
.
RemoveUnsupportedTests
(
golden
))
# This code is very handy when debugging
test differences so I left it
# here, commented.
#
open(os.path.join(
#
gtest_test_utils.GetSourceDir(),
#
'_gtest_output_test_normalized_actual.txt'), 'wb').write(
#
normalized_actual)
#
open(os.path.join(
#
gtest_test_utils.GetSourceDir(),
#
'_gtest_output_test_normalized_golden.txt'), 'wb').write(
#
normalized_golden)
# This code is very handy when debugging
golden file differences:
if
os
.
getenv
(
'DEBUG_GTEST_OUTPUT_TEST'
):
open
(
os
.
path
.
join
(
gtest_test_utils
.
GetSourceDir
(),
'_gtest_output_test_normalized_actual.txt'
),
'wb'
)
.
write
(
normalized_actual
)
open
(
os
.
path
.
join
(
gtest_test_utils
.
GetSourceDir
(),
'_gtest_output_test_normalized_golden.txt'
),
'wb'
)
.
write
(
normalized_golden
)
self
.
assert_
(
normalized_golden
==
normalized_actual
)
...
...
test/gtest_unittest.cc
View file @
88e97c82
...
...
@@ -1111,8 +1111,6 @@ TEST(StringTest, Constructors) {
EXPECT_EQ
(
'c'
,
s7
.
c_str
()[
3
]);
}
#if GTEST_HAS_STD_STRING
TEST
(
StringTest
,
ConvertsFromStdString
)
{
// An empty std::string.
const
std
::
string
src1
(
""
);
...
...
@@ -1152,8 +1150,6 @@ TEST(StringTest, ConvertsToStdString) {
EXPECT_EQ
(
std
::
string
(
"x
\0
y"
,
3
),
dest3
);
}
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_GLOBAL_STRING
TEST
(
StringTest
,
ConvertsFromGlobalString
)
{
...
...
@@ -2818,8 +2814,6 @@ TEST(IsSubstringTest, GeneratesCorrectMessageForCString) {
"needle"
,
"haystack"
).
failure_message
());
}
#if GTEST_HAS_STD_STRING
// Tests that IsSubstring returns the correct result when the input
// argument type is ::std::string.
TEST
(
IsSubstringTest
,
ReturnsCorrectResultsForStdString
)
{
...
...
@@ -2827,8 +2821,6 @@ TEST(IsSubstringTest, ReturnsCorrectResultsForStdString) {
EXPECT_FALSE
(
IsSubstring
(
""
,
""
,
"hello"
,
std
::
string
(
"world"
)));
}
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_STD_WSTRING
// Tests that IsSubstring returns the correct result when the input
// argument type is ::std::wstring.
...
...
@@ -2879,8 +2871,6 @@ TEST(IsNotSubstringTest, GeneratesCorrectMessageForWideCString) {
L"needle"
,
L"two needles"
).
failure_message
());
}
#if GTEST_HAS_STD_STRING
// Tests that IsNotSubstring returns the correct result when the input
// argument type is ::std::string.
TEST
(
IsNotSubstringTest
,
ReturnsCorrectResultsForStdString
)
{
...
...
@@ -2900,8 +2890,6 @@ TEST(IsNotSubstringTest, GeneratesCorrectMessageForStdString) {
::
std
::
string
(
"needle"
),
"two needles"
).
failure_message
());
}
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_STD_WSTRING
// Tests that IsNotSubstring returns the correct result when the input
...
...
@@ -4575,7 +4563,6 @@ TEST(StreamableToStringTest, NullCString) {
// Tests using streamable values as assertion messages.
#if GTEST_HAS_STD_STRING
// Tests using std::string as an assertion message.
TEST
(
StreamableTest
,
string
)
{
static
const
std
::
string
str
(
...
...
@@ -4596,8 +4583,6 @@ TEST(StreamableTest, stringWithEmbeddedNUL) {
"Here's a NUL
\\
0 and some more string"
);
}
#endif // GTEST_HAS_STD_STRING
// Tests that we can output a NUL char.
TEST
(
StreamableTest
,
NULChar
)
{
EXPECT_FATAL_FAILURE
({
// NOLINT
...
...
@@ -4720,7 +4705,6 @@ TEST(EqAssertionTest, WideChar) {
"Value of: wchar"
);
}
#if GTEST_HAS_STD_STRING
// Tests using ::std::string values in {EXPECT|ASSERT}_EQ.
TEST
(
EqAssertionTest
,
StdString
)
{
// Compares a const char* to an std::string that has identical
...
...
@@ -4751,8 +4735,6 @@ TEST(EqAssertionTest, StdString) {
" Actual:
\"
A
\\
0 in the middle
\"
"
);
}
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_STD_WSTRING
// Tests using ::std::wstring values in {EXPECT|ASSERT}_EQ.
...
...
test/run_tests_util.py
View file @
88e97c82
...
...
@@ -152,6 +152,20 @@ def _GetGtestBuildDir(injected_os, script_dir, config):
'gtest/scons'
))
def
_GetConfigFromBuildDir
(
build_dir
):
"""Extracts the configuration name from the build directory."""
# We don't want to depend on build_dir containing the correct path
# separators.
m
=
re
.
match
(
r'.*[\\/]([^\\/]+)[\\/][^\\/]+[\\/]scons[\\/]?$'
,
build_dir
)
if
m
:
return
m
.
group
(
1
)
else
:
print
>>
sys
.
stderr
,
(
'
%
s is an invalid build directory that does not '
'correspond to any configuration.'
%
(
build_dir
,))
return
''
# All paths in this script are either absolute or relative to the current
# working directory, unless otherwise specified.
class
TestRunner
(
object
):
...
...
@@ -270,7 +284,8 @@ class TestRunner(object):
args
,
named_configurations
,
built_configurations
,
available_configurations
=
CONFIGS
):
available_configurations
=
CONFIGS
,
python_tests_to_skip
=
None
):
"""Determines what tests should be run.
Args:
...
...
@@ -278,7 +293,9 @@ class TestRunner(object):
named_configurations: The list of configurations specified via -c or -a.
built_configurations: True if -b has been specified.
available_configurations: a list of configurations available on the
current platform, injectable for testing.
current platform, injectable for testing.
python_tests_to_skip: a collection of (configuration, python test name)s
that need to be skipped.
Returns:
A tuple with 2 elements: the list of Python tests to run and the list of
...
...
@@ -356,7 +373,13 @@ class TestRunner(object):
python_test_pairs
=
[]
for
directory
in
build_dirs
:
for
test
in
selected_python_tests
:
python_test_pairs
.
append
((
directory
,
test
))
config
=
_GetConfigFromBuildDir
(
directory
)
file_name
=
os
.
path
.
basename
(
test
)
if
python_tests_to_skip
and
(
config
,
file_name
)
in
python_tests_to_skip
:
print
(
'NOTE:
%
s is skipped for configuration
%
s, as it does not '
'work there.'
%
(
file_name
,
config
))
else
:
python_test_pairs
.
append
((
directory
,
test
))
binary_test_pairs
=
[]
for
directory
in
build_dirs
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment