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).


git-svn-id: http://googletest.googlecode.com/svn/trunk@339 861a406c-534a-0410-8894-cb66d6ee9925
diff --git a/include/gtest/internal/gtest-param-util-generated.h b/include/gtest/internal/gtest-param-util-generated.h
index 04f4c3a..ab4ab56 100644
--- a/include/gtest/internal/gtest-param-util-generated.h
+++ b/include/gtest/internal/gtest-param-util-generated.h
@@ -53,6 +53,21 @@
 #if GTEST_HAS_PARAM_TEST
 
 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 {
 
 // Used in the Values() function to provide polymorphic capabilities.
diff --git a/include/gtest/internal/gtest-param-util-generated.h.pump b/include/gtest/internal/gtest-param-util-generated.h.pump
index 8cfcf0b..baedfbc 100644
--- a/include/gtest/internal/gtest-param-util-generated.h.pump
+++ b/include/gtest/internal/gtest-param-util-generated.h.pump
@@ -54,6 +54,21 @@
 #if GTEST_HAS_PARAM_TEST
 
 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 {
 
 // Used in the Values() function to provide polymorphic capabilities.
diff --git a/run_tests.py b/run_tests.py
index 67014f3..6f11bc2 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -50,7 +50,7 @@
               Specify build directories via build configurations.
               CONFIGURATIONS is either a comma-separated list of build
               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
               listed in KNOWN BUILD DIRECTORIES section below.
 
@@ -98,16 +98,16 @@
       defines them as follows (the default build directory is the first one
       listed in each group):
       On Windows:
-              <gtest root>/scons/build/win-dbg8/scons/
-              <gtest root>/scons/build/win-opt8/scons/
-              <gtest root>/scons/build/win-dbg/scons/
-              <gtest root>/scons/build/win-opt/scons/
+              <gtest root>/scons/build/win-dbg8/gtest/scons/
+              <gtest root>/scons/build/win-opt8/gtest/scons/
+              <gtest root>/scons/build/win-dbg/gtest/scons/
+              <gtest root>/scons/build/win-opt/gtest/scons/
       On Mac:
-              <gtest root>/scons/build/mac-dbg/scons/
-              <gtest root>/scons/build/mac-opt/scons/
+              <gtest root>/scons/build/mac-dbg/gtest/scons/
+              <gtest root>/scons/build/mac-opt/gtest/scons/
       On other platforms:
-              <gtest root>/scons/build/dbg/scons/
-              <gtest root>/scons/build/opt/scons/
+              <gtest root>/scons/build/dbg/gtest/scons/
+              <gtest root>/scons/build/opt/gtest/scons/
 
 AUTHOR
        Written by Zhanyong Wan (wan@google.com)
@@ -177,7 +177,10 @@
     """Returns the build directory for a given configuration."""
 
     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):
     """Runs the executable with given args (args[0] is the executable name).
diff --git a/scons/SConscript b/scons/SConscript
index e1ccb7e..25220ee 100644
--- a/scons/SConscript
+++ b/scons/SConscript
@@ -99,34 +99,34 @@
 env = env.Clone()
 
 BUILD_TESTS = env.get('GTEST_BUILD_TESTS', False)
-if BUILD_TESTS:
-  common_exports = SConscript('SConscript.common')
-  EnvCreator = common_exports['EnvCreator']
+common_exports = SConscript('SConscript.common')
+EnvCreator = common_exports['EnvCreator']
 
 # 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
 # the main SConstruct file, prepend the path with the # sign.
 #
-# But if a project uses variant builds without source duplication, the 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>/scons.
+# But if a project uses variant builds without source duplication (see
+# http://www.scons.org/wiki/VariantDir%28%29 for more information), the
+# 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
 # directory or the 'include' subdirectory of it, and this SConscript
 # file is one directory deeper than the gtest directory.
 env.Prepend(CPPPATH = ['..', '../include'])
 
-if BUILD_TESTS:
-  env_use_own_tuple = EnvCreator.Create(env, EnvCreator.UseOwnTuple)
-  env_less_optimized = EnvCreator.Create(env, EnvCreator.LessOptimized)
-  env_with_threads = EnvCreator.Create(env, EnvCreator.WithThreads)
-  # The following environments are used to compile gtest_unittest.cc, which
-  # triggers a warning  in all but the most recent GCC versions when compiling
-  # the EXPECT_EQ(NULL, ptr) statement.
-  env_warning_ok = EnvCreator.Create(env, EnvCreator.WarningOk)
-  env_with_exceptions = EnvCreator.Create(env_warning_ok,
-                                          EnvCreator.WithExceptions)
-  env_without_rtti = EnvCreator.Create(env_warning_ok, EnvCreator.NoRtti)
+env_use_own_tuple = EnvCreator.Create(env, EnvCreator.UseOwnTuple)
+env_less_optimized = EnvCreator.Create(env, EnvCreator.LessOptimized)
+env_with_threads = EnvCreator.Create(env, EnvCreator.WithThreads)
+# The following environments are used to compile gtest_unittest.cc, which
+# triggers a warning  in all but the most recent GCC versions when compiling
+# the EXPECT_EQ(NULL, ptr) statement.
+env_warning_ok = EnvCreator.Create(env, EnvCreator.WarningOk)
+env_with_exceptions = EnvCreator.Create(env_warning_ok,
+                                        EnvCreator.WithExceptions)
+env_without_rtti = EnvCreator.Create(env_warning_ok, EnvCreator.NoRtti)
 
 ############################################################
 # Helpers for creating build targets.
@@ -229,10 +229,9 @@
 # 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.
 gtest, gtest_main = GtestStaticLibraries(env)
-if BUILD_TESTS:
-  gtest_ex, gtest_main_ex = GtestStaticLibraries(env_with_exceptions)
-  gtest_no_rtti, gtest_main_no_rtti = GtestStaticLibraries(env_without_rtti)
-  gtest_use_own_tuple, gtest_use_own_tuple_main = GtestStaticLibraries(
+gtest_ex, gtest_main_ex = GtestStaticLibraries(env_with_exceptions)
+gtest_no_rtti, gtest_main_no_rtti = GtestStaticLibraries(env_without_rtti)
+gtest_use_own_tuple, gtest_main_use_own_tuple = GtestStaticLibraries(
       env_use_own_tuple)
 
 # Install the libraries if needed.
@@ -282,10 +281,10 @@
   GtestTest(env_with_threads, 'gtest_stress_test', gtest)
   GtestTest(env_less_optimized, 'gtest_env_var_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,
               'gtest_use_own_tuple_test',
-              gtest_use_own_tuple_main,
+              gtest_main_use_own_tuple,
               ['../test/gtest-param-test_test.cc',
                '../test/gtest-param-test2_test.cc'])
   GtestBinary(env_with_exceptions, 'gtest_ex_unittest', gtest_main_ex,
@@ -320,16 +319,16 @@
 
 gtest_exports = {'gtest': gtest,
                  '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.
                  'GtestObject': GtestObject,
                  'GtestBinary': GtestBinary,
                  '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.
 Return('gtest_exports')
diff --git a/scons/SConstruct.common b/scons/SConstruct.common
index d9915b9..ed896d0 100644
--- a/scons/SConstruct.common
+++ b/scons/SConstruct.common
@@ -243,10 +243,8 @@
       # Invokes SConscript with variant_dir being build/<config name>.
       # Counter-intuitively, src_dir is relative to the build dir and has
       # to be '..' to point to the scons directory.
-      SConscript('SConscript',
-                 src_dir='..',
-                 variant_dir=env['BUILD_DIR'],
-                 duplicate=0)
+      VariantDir(env['BUILD_DIR'], src_dir='../..', duplicate=0);
+      SConscript(env['BUILD_DIR'] + '/gtest/scons/SConscript')
 
 
 sconstruct_helper = SConstructHelper()
diff --git a/test/gtest-port_test.cc b/test/gtest-port_test.cc
index df59f9e..0fbe5c5 100644
--- a/test/gtest-port_test.cc
+++ b/test/gtest-port_test.cc
@@ -161,6 +161,8 @@
 
 #if GTEST_USES_POSIX_RE
 
+#if GTEST_HAS_TYPED_TEST
+
 template <typename Str>
 class RETest : public ::testing::Test {};
 
@@ -223,6 +225,8 @@
   EXPECT_FALSE(RE::PartialMatch(TypeParam("zza"), re));
 }
 
+#endif  // GTEST_HAS_TYPED_TEST
+
 #elif GTEST_USES_SIMPLE_RE
 
 TEST(IsInSetTest, NulCharIsNotInAnySet) {
diff --git a/test/run_tests_test.py b/test/run_tests_test.py
index 79524a6..a9f0b5d 100755
--- a/test/run_tests_test.py
+++ b/test/run_tests_test.py
@@ -42,9 +42,9 @@
 import run_tests
 
 
-GTEST_DBG_DIR = 'scons/build/dbg/scons'
-GTEST_OPT_DIR = 'scons/build/opt/scons'
-GTEST_OTHER_DIR = 'scons/build/other/scons'
+GTEST_DBG_DIR = 'scons/build/dbg/gtest/scons'
+GTEST_OPT_DIR = 'scons/build/opt/gtest/scons'
+GTEST_OTHER_DIR = 'scons/build/other/gtest/scons'
 
 
 def AddExeExtension(path):