summaryrefslogtreecommitdiffstats
path: root/scons
diff options
context:
space:
mode:
authorvladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2008-11-20 01:40:35 (GMT)
committervladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2008-11-20 01:40:35 (GMT)
commit3d7042176307f0d7700a3640f3b3bcc8790b8fcd (patch)
treeec4a9020570acc6d09366e5b305b9d162c1a6026 /scons
parentb6a296d0f7caff7140f422e49f5398c9ef17504d (diff)
downloadgoogletest-3d7042176307f0d7700a3640f3b3bcc8790b8fcd.zip
googletest-3d7042176307f0d7700a3640f3b3bcc8790b8fcd.tar.gz
googletest-3d7042176307f0d7700a3640f3b3bcc8790b8fcd.tar.bz2
Value-parameterized tests and many bugfixes
Diffstat (limited to 'scons')
-rw-r--r--scons/SConscript64
1 files changed, 51 insertions, 13 deletions
diff --git a/scons/SConscript b/scons/SConscript
index 8c2f9e4..dc1423e 100644
--- a/scons/SConscript
+++ b/scons/SConscript
@@ -67,7 +67,7 @@ to the following:
# Build gtest library; as it is outside of our source root, we need to
# tell SCons that the directory it will refer to as
-# e.g. $BUIlD_DIR/gtest is actually on disk in original form as
+# e.g. $BUILD_DIR/gtest is actually on disk in original form as
# ../../gtest (relative to your project root directory). Recall that
# SCons by default copies all source files into the build directory
# before building.
@@ -102,11 +102,6 @@ env = env.Clone()
env.Prepend(CPPPATH = ['..',
'../include'])
-# TODO(joi@google.com) Fix the code that causes this warning so that
-# we see all warnings from the compiler about possible 64-bit porting
-# issues.
-env.Append(CCFLAGS=['-wd4267'])
-
# Sources shared by base library and library that includes main.
gtest_sources = ['../src/gtest-all.cc']
@@ -125,23 +120,32 @@ if 'LIB_OUTPUT' in env.Dictionary():
env.Install('$LIB_OUTPUT', source=[gtest, gtest_main])
-def GtestUnitTest(env, target, gtest_lib, additional_sources=None):
- """Helper to create gtest unit tests.
+def GtestBinary(env, target, dir_prefix, gtest_lib, additional_sources=None):
+ """Helper to create gtest binaries: tests, samples, etc.
Args:
env: The SCons construction environment to use to build.
- target: The basename of the target unit test .cc file.
+ target: The basename of the target's main source file, also used as target
+ name.
+ dir_prefix: The path to prefix the main source file.
gtest_lib: The gtest lib to use.
"""
- source = [env.File('%s.cc' % target, env.Dir('../test'))]
+ source = [env.File('%s.cc' % target, env.Dir(dir_prefix))]
if additional_sources:
source += additional_sources
- unit_test = env.Program(target=target,
- source=source,
- LIBS=[gtest_lib, 'kernel32.lib', 'user32.lib'])
+ unit_test = env.Program(target=target, source=source, LIBS=[gtest_lib])
if 'EXE_OUTPUT' in env.Dictionary():
env.Install('$EXE_OUTPUT', source=[unit_test])
+def GtestUnitTest(env, target, gtest_lib, additional_sources=None):
+ """Helper to create gtest unit tests.
+
+ Args:
+ env: The SCons construction environment to use to build.
+ target: The basename of the target unit test .cc file.
+ gtest_lib: The gtest lib to use.
+ """
+ GtestBinary(env, target, "../test", gtest_lib, additional_sources)
GtestUnitTest(env, 'gtest-filepath_test', gtest_main)
GtestUnitTest(env, 'gtest-message_test', gtest_main)
@@ -157,9 +161,13 @@ GtestUnitTest(env, 'gtest_sole_header_test', gtest_main)
GtestUnitTest(env, 'gtest-test-part_test', gtest_main)
GtestUnitTest(env, 'gtest-typed-test_test', gtest_main,
additional_sources=['../test/gtest-typed-test2_test.cc'])
+GtestUnitTest(env, 'gtest-param-test_test', gtest,
+ additional_sources=['../test/gtest-param-test2_test.cc'])
GtestUnitTest(env, 'gtest_unittest', gtest)
GtestUnitTest(env, 'gtest_output_test_', gtest)
GtestUnitTest(env, 'gtest_color_test_', gtest)
+GtestUnitTest(env, 'gtest-linked_ptr_test', gtest_main)
+GtestUnitTest(env, 'gtest-port_test', gtest_main)
# TODO(wan@google.com) Add these unit tests:
# - gtest_break_on_failure_unittest_
@@ -179,3 +187,33 @@ for flag in ["/O1", "/Os", "/Og", "/Oy"]:
linker_flags.remove(flag)
GtestUnitTest(special_env, 'gtest_env_var_test_', gtest)
GtestUnitTest(special_env, 'gtest_uninitialized_test_', gtest)
+
+def GtestSample(env, target, gtest_lib, additional_sources=None):
+ """Helper to create gtest samples.
+
+ Args:
+ env: The SCons construction environment to use to build.
+ target: The basename of the target unit test .cc file.
+ gtest_lib: The gtest lib to use.
+ """
+ GtestBinary(env, target, "../samples", gtest_lib, additional_sources)
+
+# Use the GTEST_BUILD_SAMPLES build variable to control building of samples.
+# In your SConstruct file, add
+# vars = Variables()
+# vars.Add(BoolVariable('GTEST_BUILD_SAMPLES', 'Build samples', True))
+# my_environment = Environment(variables = vars, ...)
+# Then, in the command line use GTEST_BUILD_SAMPLES=true to enable them.
+#
+if env.get('GTEST_BUILD_SAMPLES', False):
+ sample1_obj = env.Object('../samples/sample1.cc')
+ GtestSample(env, 'sample1_unittest', gtest_main,
+ additional_sources=[sample1_obj])
+ GtestSample(env, 'sample2_unittest', gtest_main,
+ additional_sources=['../samples/sample2.cc'])
+ GtestSample(env, 'sample3_unittest', gtest_main)
+ GtestSample(env, 'sample5_unittest', gtest_main,
+ additional_sources=[sample1_obj])
+ GtestSample(env, 'sample6_unittest', gtest_main)
+ GtestSample(env, 'sample7_unittest', gtest_main)
+ GtestSample(env, 'sample8_unittest', gtest_main)