diff options
author | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2009-06-17 21:06:27 +0000 |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2009-06-17 21:06:27 +0000 |
commit | 532dc2de35f2cef191bc91c3587a9f8f4974756f (patch) | |
tree | 1dd721d45ddd731134dda23f8368781979dc0b09 /test/run_tests_test.py | |
parent | 210ea10e7ad6e27342c7d9a46c2844a9bcbad396 (diff) | |
download | googletest-532dc2de35f2cef191bc91c3587a9f8f4974756f.tar.gz googletest-532dc2de35f2cef191bc91c3587a9f8f4974756f.tar.bz2 googletest-532dc2de35f2cef191bc91c3587a9f8f4974756f.zip |
Implements a subset of TR1 tuple needed by gtest and gmock (by Zhanyong Wan); cleaned up the Python tests (by Vlad Losev); made run_tests.py invokable from any directory (by Vlad Losev).
Diffstat (limited to 'test/run_tests_test.py')
-rwxr-xr-x | test/run_tests_test.py | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/test/run_tests_test.py b/test/run_tests_test.py index 1d9f3b77..b55739ea 100755 --- a/test/run_tests_test.py +++ b/test/run_tests_test.py @@ -48,6 +48,8 @@ class FakePath(object): self.tree = {} self.path_separator = os.sep + # known_paths contains either absolute or relative paths. Relative paths + # are absolutized with self.current_dir. if known_paths: self._AddPaths(known_paths) @@ -91,8 +93,11 @@ class FakePath(object): return tree + def normpath(self, path): + return os.path.normpath(path) + def abspath(self, path): - return os.path.normpath(os.path.join(self.current_dir, path)) + return self.normpath(os.path.join(self.current_dir, path)) def isfile(self, path): return self.PathElement(self.abspath(path)) == 1 @@ -157,7 +162,8 @@ class GetTestsToRunTest(unittest.TestCase): 'test/gtest_color_test.py'])) self.fake_configurations = ['dbg', 'opt'] self.test_runner = run_tests.TestRunner(injected_os=self.fake_os, - injected_subprocess=None) + injected_subprocess=None, + injected_script_dir='.') def testBinaryTestsOnly(self): """Exercises GetTestsToRun with parameters designating binary tests only.""" @@ -388,7 +394,8 @@ class GetTestsToRunTest(unittest.TestCase): 'scons/build/opt/scons/gtest_nontest.exe', 'test/'])) self.test_runner = run_tests.TestRunner(injected_os=self.fake_os, - injected_subprocess=None) + injected_subprocess=None, + injected_script_dir='.') self.AssertResultsEqual( self.test_runner.GetTestsToRun( [], @@ -397,6 +404,43 @@ class GetTestsToRunTest(unittest.TestCase): available_configurations=self.fake_configurations), ([], [])) + def testWorksFromDifferentDir(self): + """Exercises GetTestsToRun from a directory different from run_test.py's.""" + + # Here we simulate an test script in directory /d/ called from the + # directory /a/b/c/. + self.fake_os = FakeOs(FakePath( + current_dir=os.path.abspath('/a/b/c'), + known_paths=['/a/b/c/', + '/d/scons/build/dbg/scons/gtest_unittest', + '/d/scons/build/opt/scons/gtest_unittest', + '/d/test/gtest_color_test.py'])) + self.fake_configurations = ['dbg', 'opt'] + self.test_runner = run_tests.TestRunner(injected_os=self.fake_os, + injected_subprocess=None, + injected_script_dir='/d/') + # A binary test. + self.AssertResultsEqual( + self.test_runner.GetTestsToRun( + ['gtest_unittest'], + '', + False, + available_configurations=self.fake_configurations), + ([], + [('/d/scons/build/dbg/scons', + '/d/scons/build/dbg/scons/gtest_unittest')])) + + # A Python test. + self.AssertResultsEqual( + self.test_runner.GetTestsToRun( + ['gtest_color_test.py'], + '', + False, + available_configurations=self.fake_configurations), + ([('/d/scons/build/dbg/scons', '/d/test/gtest_color_test.py')], + [])) + + def testNonTestBinary(self): """Exercises GetTestsToRun with a non-test parameter.""" |