コード例 #1
0
def _Main():
    """Runs all tests for Google Test."""

    options, args = run_tests_util.ParseArgs('gtest')
    test_runner = run_tests_util.TestRunner(script_dir=SCRIPT_DIR)
    tests = test_runner.GetTestsToRun(args, options.configurations,
                                      options.built_configurations)
    if not tests:
        sys.exit(1)  # Incorrect parameters given, abort execution.

    sys.exit(test_runner.RunTests(tests[0], tests[1]))
 def setUp(self):
     self.fake_os = FakeOs(
         FakePath(current_dir=os.path.abspath(
             os.path.dirname(run_tests_util.__file__)),
                  known_paths=[
                      AddExeExtension(GTEST_DBG_DIR + '/gtest_unittest'),
                      AddExeExtension(GTEST_OPT_DIR + '/gtest_unittest'),
                      'test/gtest_color_test.py'
                  ]))
     self.fake_configurations = ['dbg', 'opt']
     self.test_runner = run_tests_util.TestRunner(script_dir='.',
                                                  injected_os=self.fake_os,
                                                  injected_subprocess=None)
コード例 #3
0
ファイル: run_tests.py プロジェクト: IsaiahKing/glopen
def _Main():
    """Runs all tests for Google Mock."""

    options, args = run_tests_util.ParseArgs('gtest')
    test_runner = run_tests_util.TestRunner(
        script_dir=SCRIPT_DIR,
        build_dir_var_name='GMOCK_BUILD_DIR',
        injected_build_dir_finder=GetGmockBuildDir)
    tests = test_runner.GetTestsToRun(args, options.configurations,
                                      options.built_configurations)
    if not tests:
        sys.exit(1)  # Incorrect parameters given, abort execution.

    sys.exit(test_runner.RunTests(tests[0], tests[1]))
    def testIgnoresNonTestFiles(self):
        """Verifies that GetTestsToRun ignores non-test files in the filesystem."""

        self.fake_os = FakeOs(
            FakePath(current_dir=os.path.abspath(
                os.path.dirname(run_tests_util.__file__)),
                     known_paths=[
                         AddExeExtension(GTEST_DBG_DIR + '/gtest_nontest'),
                         'test/'
                     ]))
        self.test_runner = run_tests_util.TestRunner(script_dir='.',
                                                     injected_os=self.fake_os,
                                                     injected_subprocess=None)
        self.AssertResultsEqual(
            self.test_runner.GetTestsToRun(
                [],
                '',
                True,
                available_configurations=self.fake_configurations), ([], []))
        def testDoesNotPickNonExeFilesOnWindows(self):
            """Verifies that GetTestsToRun does not find _test files on Windows."""

            self.fake_os = FakeOs(
                FakePath(current_dir=os.path.abspath(
                    os.path.dirname(run_tests_util.__file__)),
                         known_paths=[
                             '/d/' + GTEST_DBG_DIR + '/gtest_test', 'test/'
                         ]))
            self.test_runner = run_tests_util.TestRunner(
                script_dir='.',
                injected_os=self.fake_os,
                injected_subprocess=None)
            self.AssertResultsEqual(
                self.test_runner.GetTestsToRun(
                    [],
                    '',
                    True,
                    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/',
                    AddExeExtension('/d/' + GTEST_DBG_DIR + '/gtest_unittest'),
                    AddExeExtension('/d/' + GTEST_OPT_DIR + '/gtest_unittest'),
                    '/d/test/gtest_color_test.py'
                ]))
        self.fake_configurations = ['dbg', 'opt']
        self.test_runner = run_tests_util.TestRunner(script_dir='/d/',
                                                     injected_os=self.fake_os,
                                                     injected_subprocess=None)
        # A binary test.
        self.AssertResultsEqual(
            self.test_runner.GetTestsToRun(
                ['gtest_unittest'],
                '',
                False,
                available_configurations=self.fake_configurations),
            ([], [('/d/' + GTEST_DBG_DIR,
                   '/d/' + GTEST_DBG_DIR + '/gtest_unittest')]))

        # A Python test.
        self.AssertResultsEqual(
            self.test_runner.GetTestsToRun(
                ['gtest_color_test.py'],
                '',
                False,
                available_configurations=self.fake_configurations),
            ([('/d/' + GTEST_DBG_DIR, '/d/test/gtest_color_test.py')], []))