Exemple #1
0
    def test_get_run_results_checker_id_and_file_path(self):
        """ Test if all the bugs are found based
            on the test project configuration. """
        runid = self._runid
        logging.debug('Get all run results from the db for runid: ' +
                      str(runid))

        run_result_count = self._cc_client.getRunResultCount(runid, [])
        self.assertTrue(run_result_count)

        run_results = get_all_run_results(self._cc_client, runid)
        self.assertIsNotNone(run_results)
        self.assertEqual(run_result_count, len(run_results))

        test_project_results = self._testproject_data[
            self._clang_to_test]['bugs']
        for r in test_project_results:
            print(r)

        not_found = find_all(run_results, test_project_results)

        print_run_results(run_results)

        if not_found:
            print("===================")
            print('Not found bugs:')
            for bug in not_found:
                print(bug)
            print("===================")

        self.assertEqual(len(not_found), 0)
    def test_get_run_results_checker_id_and_file_path(self):
        """ Test if all the bugs are found based
            on the test project configuration. """
        runid = self._runid
        logging.debug('Get all run results from the db for runid: ' +
                      str(runid))

        run_result_count = self._cc_client.getRunResultCount([runid],
                                                             None,
                                                             None)
        self.assertTrue(run_result_count)

        run_results = get_all_run_results(self._cc_client, runid)
        self.assertIsNotNone(run_results)
        self.assertEqual(run_result_count, len(run_results))

        test_project_results = self._testproject_data[
            self._clang_to_test]['bugs']
        for r in test_project_results:
            print(r)

        not_found = find_all(run_results, test_project_results)

        print_run_results(run_results)

        if not_found:
            print("===================")
            print('Not found bugs:')
            for bug in not_found:
                print(bug)
            print("===================")

        self.assertEqual(len(not_found), 0)
    def test_skip(self):
        """ There should be no results from the skipped file. """

        runid = self._runid
        logging.debug('Get all run results from the db for runid: ' +
                      str(runid))

        run_results = get_all_run_results(self._cc_client, runid)
        self.assertIsNotNone(run_results)

        skipped_files = ["file_to_be_skipped.cpp", "skip.h", "path_end.h"]

        # IMPORTANT: This test is checking whether some reports are really not
        # stored because they were skipped during analysis with --skip flag.
        # However, since clang-tidy is not run, there will be no reports from
        # "clang-diagnostic" checker. These are handled separately here,
        # otherwise the test would believe they're missing because of --skip
        # which is not the case.

        test_proj_res = self._testproject_data[self._clang_to_test]['bugs']
        skipped = [
            x for x in test_proj_res if x['file'] in skipped_files
            or x['checker'].startswith('clang-diagnostic-')
        ]

        print("Analysis:")
        for res in run_results:
            print(res)

        print("\nTest config results:")
        for res in test_proj_res:
            print(res)

        print("\nTest config skipped results:")
        for res in skipped:
            print(res)

        missing_results = find_all(run_results, test_proj_res)

        print_run_results(run_results)

        print('Missing results:')
        for mr in missing_results:
            print(mr)

        if missing_results:
            for bug in missing_results:
                if not bug['checker'].startswith('clang-diagnostic-'):
                    self.assertIn(bug['file'], skipped_files)
        else:
            self.assertTrue(
                True, "There should be missing results because"
                "using skip")

        self.assertEqual(len(run_results), len(test_proj_res) - len(skipped))
Exemple #4
0
    def test_skip(self):
        """ There should be no results from the skipped file. """

        runid = self._runid
        logging.debug('Get all run results from the db for runid: ' +
                      str(runid))

        run_results = get_all_run_results(self._cc_client, runid)
        self.assertIsNotNone(run_results)

        skipped_files = ["file_to_be_skipped.cpp", "skip.h"]

        test_proj_res = self._testproject_data[self._clang_to_test]['bugs']
        skipped = [x for x in test_proj_res if x['file'] in skipped_files]

        print("Analysis:")
        for res in run_results:
            print(res)

        print("\nTest config results:")
        for res in test_proj_res:
            print(res)

        print("\nTest config skipped results:")
        for res in skipped:
            print(res)

        missing_results = find_all(run_results, test_proj_res)

        print_run_results(run_results)

        print('Missing results:')
        for mr in missing_results:
            print(mr)

        if missing_results:
            for bug in missing_results:
                self.assertIn(bug['file'], skipped_files)
        else:
            self.assertTrue(True,
                            "There should be missing results because"
                            "using skip")

        self.assertEqual(len(run_results), len(test_proj_res) - len(skipped))