Improves the scons scripts and run_tests.py (by Vlad Losev); uses typed tests in gtest-port_test.cc only when typed tests are available (by Zhanyong Wan); makes gtest-param-util-generated.h conform to the C++ standard (by Zhanyong Wan).
This commit is contained in:
parent
7e13e0f5dd
commit
bcf926ec65
|
@ -53,6 +53,21 @@
|
||||||
#if GTEST_HAS_PARAM_TEST
|
#if GTEST_HAS_PARAM_TEST
|
||||||
|
|
||||||
namespace testing {
|
namespace testing {
|
||||||
|
|
||||||
|
// Forward declarations of ValuesIn(), which is implemented in
|
||||||
|
// include/gtest/gtest-param-test.h.
|
||||||
|
template <typename ForwardIterator>
|
||||||
|
internal::ParamGenerator<
|
||||||
|
typename ::std::iterator_traits<ForwardIterator>::value_type> ValuesIn(
|
||||||
|
ForwardIterator begin, ForwardIterator end);
|
||||||
|
|
||||||
|
template <typename T, size_t N>
|
||||||
|
internal::ParamGenerator<T> ValuesIn(const T (&array)[N]);
|
||||||
|
|
||||||
|
template <class Container>
|
||||||
|
internal::ParamGenerator<typename Container::value_type> ValuesIn(
|
||||||
|
const Container& container);
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
// Used in the Values() function to provide polymorphic capabilities.
|
// Used in the Values() function to provide polymorphic capabilities.
|
||||||
|
|
|
@ -54,6 +54,21 @@ $var maxtuple = 10 $$ Maximum number of Combine arguments we want to support.
|
||||||
#if GTEST_HAS_PARAM_TEST
|
#if GTEST_HAS_PARAM_TEST
|
||||||
|
|
||||||
namespace testing {
|
namespace testing {
|
||||||
|
|
||||||
|
// Forward declarations of ValuesIn(), which is implemented in
|
||||||
|
// include/gtest/gtest-param-test.h.
|
||||||
|
template <typename ForwardIterator>
|
||||||
|
internal::ParamGenerator<
|
||||||
|
typename ::std::iterator_traits<ForwardIterator>::value_type> ValuesIn(
|
||||||
|
ForwardIterator begin, ForwardIterator end);
|
||||||
|
|
||||||
|
template <typename T, size_t N>
|
||||||
|
internal::ParamGenerator<T> ValuesIn(const T (&array)[N]);
|
||||||
|
|
||||||
|
template <class Container>
|
||||||
|
internal::ParamGenerator<typename Container::value_type> ValuesIn(
|
||||||
|
const Container& container);
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
// Used in the Values() function to provide polymorphic capabilities.
|
// Used in the Values() function to provide polymorphic capabilities.
|
||||||
|
|
23
run_tests.py
23
run_tests.py
|
@ -50,7 +50,7 @@ OPTIONS
|
||||||
Specify build directories via build configurations.
|
Specify build directories via build configurations.
|
||||||
CONFIGURATIONS is either a comma-separated list of build
|
CONFIGURATIONS is either a comma-separated list of build
|
||||||
configurations or 'all'. Each configuration is equivalent to
|
configurations or 'all'. Each configuration is equivalent to
|
||||||
adding 'scons/build/<configuration>/scons' to BUILD_DIRs.
|
adding 'scons/build/<configuration>/gtest/scons' to BUILD_DIRs.
|
||||||
Specifying -c=all is equivalent to providing all directories
|
Specifying -c=all is equivalent to providing all directories
|
||||||
listed in KNOWN BUILD DIRECTORIES section below.
|
listed in KNOWN BUILD DIRECTORIES section below.
|
||||||
|
|
||||||
|
@ -98,16 +98,16 @@ KNOWN BUILD DIRECTORIES
|
||||||
defines them as follows (the default build directory is the first one
|
defines them as follows (the default build directory is the first one
|
||||||
listed in each group):
|
listed in each group):
|
||||||
On Windows:
|
On Windows:
|
||||||
<gtest root>/scons/build/win-dbg8/scons/
|
<gtest root>/scons/build/win-dbg8/gtest/scons/
|
||||||
<gtest root>/scons/build/win-opt8/scons/
|
<gtest root>/scons/build/win-opt8/gtest/scons/
|
||||||
<gtest root>/scons/build/win-dbg/scons/
|
<gtest root>/scons/build/win-dbg/gtest/scons/
|
||||||
<gtest root>/scons/build/win-opt/scons/
|
<gtest root>/scons/build/win-opt/gtest/scons/
|
||||||
On Mac:
|
On Mac:
|
||||||
<gtest root>/scons/build/mac-dbg/scons/
|
<gtest root>/scons/build/mac-dbg/gtest/scons/
|
||||||
<gtest root>/scons/build/mac-opt/scons/
|
<gtest root>/scons/build/mac-opt/gtest/scons/
|
||||||
On other platforms:
|
On other platforms:
|
||||||
<gtest root>/scons/build/dbg/scons/
|
<gtest root>/scons/build/dbg/gtest/scons/
|
||||||
<gtest root>/scons/build/opt/scons/
|
<gtest root>/scons/build/opt/gtest/scons/
|
||||||
|
|
||||||
AUTHOR
|
AUTHOR
|
||||||
Written by Zhanyong Wan (wan@google.com)
|
Written by Zhanyong Wan (wan@google.com)
|
||||||
|
@ -177,7 +177,10 @@ class TestRunner(object):
|
||||||
"""Returns the build directory for a given configuration."""
|
"""Returns the build directory for a given configuration."""
|
||||||
|
|
||||||
return self.os.path.normpath(
|
return self.os.path.normpath(
|
||||||
self.os.path.join(self.script_dir, 'scons/build', config, 'scons'))
|
self.os.path.join(self.script_dir,
|
||||||
|
'scons/build',
|
||||||
|
config,
|
||||||
|
'gtest/scons'))
|
||||||
|
|
||||||
def Run(self, args):
|
def Run(self, args):
|
||||||
"""Runs the executable with given args (args[0] is the executable name).
|
"""Runs the executable with given args (args[0] is the executable name).
|
||||||
|
|
|
@ -99,34 +99,34 @@ Import('env')
|
||||||
env = env.Clone()
|
env = env.Clone()
|
||||||
|
|
||||||
BUILD_TESTS = env.get('GTEST_BUILD_TESTS', False)
|
BUILD_TESTS = env.get('GTEST_BUILD_TESTS', False)
|
||||||
if BUILD_TESTS:
|
common_exports = SConscript('SConscript.common')
|
||||||
common_exports = SConscript('SConscript.common')
|
EnvCreator = common_exports['EnvCreator']
|
||||||
EnvCreator = common_exports['EnvCreator']
|
|
||||||
|
|
||||||
# Note: The relative paths in SConscript files are relative to the location
|
# Note: The relative paths in SConscript files are relative to the location
|
||||||
# of the SConscript file itself. To make a path relative to the location of
|
# of the SConscript file itself. To make a path relative to the location of
|
||||||
# the main SConstruct file, prepend the path with the # sign.
|
# the main SConstruct file, prepend the path with the # sign.
|
||||||
#
|
#
|
||||||
# But if a project uses variant builds without source duplication, the above
|
# But if a project uses variant builds without source duplication (see
|
||||||
# rule gets muddied a bit. In that case the paths must be counted from the
|
# http://www.scons.org/wiki/VariantDir%28%29 for more information), the
|
||||||
# location of the copy of the SConscript file in scons/build/<config>/scons.
|
# above rule gets muddied a bit. In that case the paths must be counted from
|
||||||
|
# the location of the copy of the SConscript file in
|
||||||
|
# scons/build/<config>/gtest/scons.
|
||||||
#
|
#
|
||||||
# Include paths to gtest headers are relative to either the gtest
|
# Include paths to gtest headers are relative to either the gtest
|
||||||
# directory or the 'include' subdirectory of it, and this SConscript
|
# directory or the 'include' subdirectory of it, and this SConscript
|
||||||
# file is one directory deeper than the gtest directory.
|
# file is one directory deeper than the gtest directory.
|
||||||
env.Prepend(CPPPATH = ['..', '../include'])
|
env.Prepend(CPPPATH = ['..', '../include'])
|
||||||
|
|
||||||
if BUILD_TESTS:
|
env_use_own_tuple = EnvCreator.Create(env, EnvCreator.UseOwnTuple)
|
||||||
env_use_own_tuple = EnvCreator.Create(env, EnvCreator.UseOwnTuple)
|
env_less_optimized = EnvCreator.Create(env, EnvCreator.LessOptimized)
|
||||||
env_less_optimized = EnvCreator.Create(env, EnvCreator.LessOptimized)
|
env_with_threads = EnvCreator.Create(env, EnvCreator.WithThreads)
|
||||||
env_with_threads = EnvCreator.Create(env, EnvCreator.WithThreads)
|
# The following environments are used to compile gtest_unittest.cc, which
|
||||||
# The following environments are used to compile gtest_unittest.cc, which
|
# triggers a warning in all but the most recent GCC versions when compiling
|
||||||
# triggers a warning in all but the most recent GCC versions when compiling
|
# the EXPECT_EQ(NULL, ptr) statement.
|
||||||
# the EXPECT_EQ(NULL, ptr) statement.
|
env_warning_ok = EnvCreator.Create(env, EnvCreator.WarningOk)
|
||||||
env_warning_ok = EnvCreator.Create(env, EnvCreator.WarningOk)
|
env_with_exceptions = EnvCreator.Create(env_warning_ok,
|
||||||
env_with_exceptions = EnvCreator.Create(env_warning_ok,
|
EnvCreator.WithExceptions)
|
||||||
EnvCreator.WithExceptions)
|
env_without_rtti = EnvCreator.Create(env_warning_ok, EnvCreator.NoRtti)
|
||||||
env_without_rtti = EnvCreator.Create(env_warning_ok, EnvCreator.NoRtti)
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# Helpers for creating build targets.
|
# Helpers for creating build targets.
|
||||||
|
@ -229,10 +229,9 @@ def GtestSample(build_env, target, additional_sources=None):
|
||||||
# gtest_main.lib can be used if you just want a basic main function; it is also
|
# gtest_main.lib can be used if you just want a basic main function; it is also
|
||||||
# used by some tests for Google Test itself.
|
# used by some tests for Google Test itself.
|
||||||
gtest, gtest_main = GtestStaticLibraries(env)
|
gtest, gtest_main = GtestStaticLibraries(env)
|
||||||
if BUILD_TESTS:
|
gtest_ex, gtest_main_ex = GtestStaticLibraries(env_with_exceptions)
|
||||||
gtest_ex, gtest_main_ex = GtestStaticLibraries(env_with_exceptions)
|
gtest_no_rtti, gtest_main_no_rtti = GtestStaticLibraries(env_without_rtti)
|
||||||
gtest_no_rtti, gtest_main_no_rtti = GtestStaticLibraries(env_without_rtti)
|
gtest_use_own_tuple, gtest_main_use_own_tuple = GtestStaticLibraries(
|
||||||
gtest_use_own_tuple, gtest_use_own_tuple_main = GtestStaticLibraries(
|
|
||||||
env_use_own_tuple)
|
env_use_own_tuple)
|
||||||
|
|
||||||
# Install the libraries if needed.
|
# Install the libraries if needed.
|
||||||
|
@ -282,10 +281,10 @@ if BUILD_TESTS:
|
||||||
GtestTest(env_with_threads, 'gtest_stress_test', gtest)
|
GtestTest(env_with_threads, 'gtest_stress_test', gtest)
|
||||||
GtestTest(env_less_optimized, 'gtest_env_var_test_', gtest)
|
GtestTest(env_less_optimized, 'gtest_env_var_test_', gtest)
|
||||||
GtestTest(env_less_optimized, 'gtest_uninitialized_test_', gtest)
|
GtestTest(env_less_optimized, 'gtest_uninitialized_test_', gtest)
|
||||||
GtestTest(env_use_own_tuple, 'gtest-tuple_test', gtest_use_own_tuple_main)
|
GtestTest(env_use_own_tuple, 'gtest-tuple_test', gtest_main_use_own_tuple)
|
||||||
GtestBinary(env_use_own_tuple,
|
GtestBinary(env_use_own_tuple,
|
||||||
'gtest_use_own_tuple_test',
|
'gtest_use_own_tuple_test',
|
||||||
gtest_use_own_tuple_main,
|
gtest_main_use_own_tuple,
|
||||||
['../test/gtest-param-test_test.cc',
|
['../test/gtest-param-test_test.cc',
|
||||||
'../test/gtest-param-test2_test.cc'])
|
'../test/gtest-param-test2_test.cc'])
|
||||||
GtestBinary(env_with_exceptions, 'gtest_ex_unittest', gtest_main_ex,
|
GtestBinary(env_with_exceptions, 'gtest_ex_unittest', gtest_main_ex,
|
||||||
|
@ -320,16 +319,16 @@ if env.get('GTEST_BUILD_SAMPLES', False):
|
||||||
|
|
||||||
gtest_exports = {'gtest': gtest,
|
gtest_exports = {'gtest': gtest,
|
||||||
'gtest_main': gtest_main,
|
'gtest_main': gtest_main,
|
||||||
|
'gtest_ex': gtest_ex,
|
||||||
|
'gtest_main_ex': gtest_main_ex,
|
||||||
|
'gtest_no_rtti': gtest_no_rtti,
|
||||||
|
'gtest_main_no_rtti': gtest_main_no_rtti,
|
||||||
|
'gtest_use_own_tuple': gtest_use_own_tuple,
|
||||||
|
'gtest_main_use_own_tuple': gtest_main_use_own_tuple,
|
||||||
# These exports are used by Google Mock.
|
# These exports are used by Google Mock.
|
||||||
'GtestObject': GtestObject,
|
'GtestObject': GtestObject,
|
||||||
'GtestBinary': GtestBinary,
|
'GtestBinary': GtestBinary,
|
||||||
'GtestTest': GtestTest}
|
'GtestTest': GtestTest}
|
||||||
|
|
||||||
if BUILD_TESTS:
|
|
||||||
# These environments are needed for tests only.
|
|
||||||
gtest_exports.update({'gtest_ex': gtest_ex,
|
|
||||||
'gtest_no_rtti': gtest_no_rtti,
|
|
||||||
'gtest_use_own_tuple': gtest_use_own_tuple})
|
|
||||||
|
|
||||||
# Makes the gtest_exports dictionary available to the invoking SConstruct.
|
# Makes the gtest_exports dictionary available to the invoking SConstruct.
|
||||||
Return('gtest_exports')
|
Return('gtest_exports')
|
||||||
|
|
|
@ -243,10 +243,8 @@ class SConstructHelper:
|
||||||
# Invokes SConscript with variant_dir being build/<config name>.
|
# Invokes SConscript with variant_dir being build/<config name>.
|
||||||
# Counter-intuitively, src_dir is relative to the build dir and has
|
# Counter-intuitively, src_dir is relative to the build dir and has
|
||||||
# to be '..' to point to the scons directory.
|
# to be '..' to point to the scons directory.
|
||||||
SConscript('SConscript',
|
VariantDir(env['BUILD_DIR'], src_dir='../..', duplicate=0);
|
||||||
src_dir='..',
|
SConscript(env['BUILD_DIR'] + '/gtest/scons/SConscript')
|
||||||
variant_dir=env['BUILD_DIR'],
|
|
||||||
duplicate=0)
|
|
||||||
|
|
||||||
|
|
||||||
sconstruct_helper = SConstructHelper()
|
sconstruct_helper = SConstructHelper()
|
||||||
|
|
|
@ -161,6 +161,8 @@ TEST(GtestCheckDeathTest, LivesSilentlyOnSuccess) {
|
||||||
|
|
||||||
#if GTEST_USES_POSIX_RE
|
#if GTEST_USES_POSIX_RE
|
||||||
|
|
||||||
|
#if GTEST_HAS_TYPED_TEST
|
||||||
|
|
||||||
template <typename Str>
|
template <typename Str>
|
||||||
class RETest : public ::testing::Test {};
|
class RETest : public ::testing::Test {};
|
||||||
|
|
||||||
|
@ -223,6 +225,8 @@ TYPED_TEST(RETest, PartialMatchWorks) {
|
||||||
EXPECT_FALSE(RE::PartialMatch(TypeParam("zza"), re));
|
EXPECT_FALSE(RE::PartialMatch(TypeParam("zza"), re));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // GTEST_HAS_TYPED_TEST
|
||||||
|
|
||||||
#elif GTEST_USES_SIMPLE_RE
|
#elif GTEST_USES_SIMPLE_RE
|
||||||
|
|
||||||
TEST(IsInSetTest, NulCharIsNotInAnySet) {
|
TEST(IsInSetTest, NulCharIsNotInAnySet) {
|
||||||
|
|
|
@ -42,9 +42,9 @@ sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), os.pardir))
|
||||||
import run_tests
|
import run_tests
|
||||||
|
|
||||||
|
|
||||||
GTEST_DBG_DIR = 'scons/build/dbg/scons'
|
GTEST_DBG_DIR = 'scons/build/dbg/gtest/scons'
|
||||||
GTEST_OPT_DIR = 'scons/build/opt/scons'
|
GTEST_OPT_DIR = 'scons/build/opt/gtest/scons'
|
||||||
GTEST_OTHER_DIR = 'scons/build/other/scons'
|
GTEST_OTHER_DIR = 'scons/build/other/gtest/scons'
|
||||||
|
|
||||||
|
|
||||||
def AddExeExtension(path):
|
def AddExeExtension(path):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user