Esempio n. 1
0
    def extract_bugs_auto_generated_test_basic_project(self):
        def is_bp_test_cases(test_case):
            return test_case.valid and test_case.type == Main.mvn_bug.Bug_type.GEN

        Main.branch_inspected = 'origin/test_extract_bugs_5'
        Main.set_up(['', 'https://github.com/rotba/MavenProj'])
        Main.USE_CACHED_STATE = False
        issue = jira.issue('TIKA-19')
        possible_bugs_extractor = JiraExtractor(
            repo_dir=Main.repo.working_dir,
            branch_inspected=Main.branch_inspected,
            jira_url='')
        commit = [
            c for c in list(Main.repo.iter_commits(Main.branch_inspected))
            if c.hexsha == '23270ce01dbf36cd0cf2ccc9438dce641822abb8'
        ][0]
        module_path = os.getcwd() + r'\tested_project\MavenProj\sub_mod_1'
        Main.repo.git.reset('--hard')
        Main.repo.git.checkout(commit.hexsha, '-f')
        tests_paths = possible_bugs_extractor.get_tests_paths_from_commit(
            commit)
        Main.GENERATE_TESTS = True
        Main.TESTS_GEN_SEED = 3333333
        res = Main.extract_bugs(
            issue, commit, tests_paths,
            possible_bugs_extractor.get_changed_components(commit))
        num_of_success_bugs = reduce(
            lambda acc, curr: acc + int(is_bp_test_cases(curr)), res, 0)
        Main.repo.git.add('--all')
        Main.repo.git.checkout('HEAD', '-f')
        print(colored("The number of BP-test-cases generated is:", 'blue'))
        print(colored(num_of_success_bugs, 'blue'))
Esempio n. 2
0
 def test_extract_bugs_delta_testcases_that_passed_in_parrent(self):
     print('test_extract_bugs_pick_up_failures')
     Main.set_up(['', 'https://github.com/rotba/MavenProj'])
     issue = jira.issue('TIKA-19')
     possible_bugs_extractor = JiraExtractor(
         repo_dir=Main.repo.working_dir,
         branch_inspected=Main.branch_inspected,
         jira_url='')
     proj_name = 'MavenProj'
     exp_testcase_id = reduce(lambda acc, curr: os.path.join(acc, curr), [
         'sub_mod_1', 'src', 'test', 'java', 'p_1',
         'AmitTest.java#AmitTest#None_deltaPassedTest()'
     ],
                              settings.ProjFiles(proj_name).repo)
     commit = [
         c for c in list(Main.repo.iter_commits(Main.branch_inspected))
         if c.hexsha == 'd03e45c84ad903435fae8f1814a56569906663eb'
     ][0]
     module_path = os.getcwd() + r'\tested_project\MavenProj\sub_mod_1'
     Main.repo.git.reset('--hard')
     Main.repo.git.checkout(commit.hexsha)
     tests_paths = possible_bugs_extractor.get_tests_paths_from_commit(
         commit)
     res = Main.extract_bugs(
         issue, commit, tests_paths,
         possible_bugs_extractor.get_changed_components(commit))
     for bug in res:
         if not bug.valid and bug.bugged_testcase.id == exp_testcase_id and bug.type == Main.mvn_bug.Bug_type.DELTA \
           and bug.desctiption == Main.mvn_bug.invalid_passed_desc:
             return
     self.fail('Did not extracted the bug of testcase -' + exp_testcase_id)
Esempio n. 3
0
 def test_extract_bugs_pick_up_failures(self):
     print('test_extract_bugs_pick_up_failures')
     Main.set_up(['', 'https://github.com/rotba/MavenProj'])
     issue = jira.issue('TIKA-19')
     possible_bugs_extractor = JiraExtractor(
         repo_dir=Main.repo.working_dir,
         branch_inspected=Main.branch_inspected,
         jira_url='')
     proj_name = 'MavenProj'
     exp_testcase_id = reduce(lambda acc, curr: os.path.join(acc, curr), [
         'sub_mod_1', 'src', 'test', 'java', 'p_1',
         'AmitTest.java#AmitTest#None_RTerrorTest()'
     ],
                              settings.ProjFiles(proj_name).repo)
     commit = [
         c for c in list(Main.repo.iter_commits(Main.branch_inspected))
         if c.hexsha == '1d3c81c1f7a4722408264cc5279df7abb22a3c04'
     ][0]
     module_path = os.getcwd() + r'\tested_project\MavenProj\sub_mod_1'
     Main.repo.git.reset('--hard')
     Main.repo.git.checkout(commit.hexsha)
     tests_paths = possible_bugs_extractor.get_tests_paths_from_commit(
         commit)
     res = Main.extract_bugs(
         issue, commit, tests_paths,
         possible_bugs_extractor.get_changed_components(commit))
     for bug in res:
         if not bug.valid and bug.bugged_testcase.id == exp_testcase_id and bug.type == Main.mvn_bug.Bug_type.REGRESSION \
           and bug.desctiption.startswith(Main.mvn_bug.invalid_rt_error_desc):
             return
     self.fail('Did not extracted the bug of testcase -' + exp_testcase_id)
Esempio n. 4
0
 def test_extract_bugs_2(self):
     Main.set_up(['', 'https://github.com/rotba/MavenProj'])
     possible_bugs_extractor = JiraExtractor(
         repo_dir=Main.repo.working_dir,
         branch_inspected=Main.branch_inspected,
         jira_url='')
     issue = jira.issue('TIKA-19')
     proj_name = 'MavenProj'
     exp_testcase_id = reduce(lambda acc, curr: os.path.join(acc, curr), [
         'sub_mod_1', 'src', 'test', 'java', 'p_1',
         'AmitTest.java#AmitTest#None_fooTest()'
     ],
                              settings.ProjFiles(proj_name).repo)
     commit = [
         c for c in list(Main.repo.iter_commits(Main.branch_inspected))
         if c.hexsha == '19f6c78889f9e929bc964d420315a043b62c7967'
     ][0]
     module_path = os.getcwd() + r'\tested_project\MavenProj\sub_mod_1'
     Main.repo.git.reset('--hard')
     Main.repo.git.checkout(commit.hexsha)
     tests_paths = possible_bugs_extractor.get_tests_paths_from_commit(
         commit)
     res = Main.extract_bugs(
         issue, commit, tests_paths,
         possible_bugs_extractor.get_changed_components(commit))
     for bug in res:
         if bug.valid and bug.bugged_testcase.id == exp_testcase_id and bug.type == Main.mvn_bug.Bug_type.DELTA:
             return
     self.fail('Did not extracted the bug of testcase -' + exp_testcase_id)
Esempio n. 5
0
 def test_extract_bugs_auto_generated_test_basic_project(self):
     Main.branch_inspected = 'origin/test_extract_bugs_5'
     Main.set_up(['', 'https://github.com/rotba/MavenProj'])
     Main.USE_CACHED_STATE = False
     issue = jira.issue('TIKA-19')
     possible_bugs_extractor = JiraExtractor(
         repo_dir=Main.repo.working_dir,
         branch_inspected=Main.branch_inspected,
         jira_url='')
     exp_testcase_id = [
         os.getcwd() +
         r'\tested_project\MavenProj\sub_mod_1\.evosuite\best-tests_ignore_ignore\p_1\Amit_ESTest.java#Amit_ESTest#None_test4()',
         os.getcwd() +
         r'\tested_project\MavenProj\sub_mod_1\.evosuite\best-tests_ignore_ignore\p_1\Amit_ESTest.java#Amit_ESTest#None_test04()',
         os.getcwd() +
         r'\tested_project\MavenProj\sub_mod_1\.evosuite\best-tests_ignore_ignore\p_1\Amit_ESTest.java#Amit_ESTest#None_test01()',
         os.getcwd() +
         r'\tested_project\MavenProj\sub_mod_1\.evosuite\best-tests_ignore_ignore\p_1\Amit_ESTest.java#Amit_ESTest#None_test00()',
         os.getcwd() +
         r'\tested_project\MavenProj\sub_mod_1\.evosuite\best-tests_ignore_ignore\p_1\Amit_ESTest.java#Amit_ESTest#None_test0()'
     ]
     commit = [
         c for c in list(Main.repo.iter_commits(Main.branch_inspected))
         if c.hexsha == '23270ce01dbf36cd0cf2ccc9438dce641822abb8'
     ][0]
     module_path = os.getcwd() + r'\tested_project\MavenProj\sub_mod_1'
     Main.repo.git.reset('--hard')
     Main.repo.git.checkout(commit.hexsha, '-f')
     tests_paths = possible_bugs_extractor.get_tests_paths_from_commit(
         commit)
     Main.GENERATE_TESTS = True
     res = Main.extract_bugs(
         issue, commit, tests_paths,
         possible_bugs_extractor.get_changed_components(commit))
     success = False
     num_of_success_bugs = 0
     for bug in res:
         if bug.valid and bug.type == Main.mvn_bug.Bug_type.GEN:
             num_of_success_bugs += 1
     Main.repo.git.add('--all')
     Main.repo.git.checkout('HEAD', '-f')
     if not 0 < num_of_success_bugs <= 3:
         self.fail('Did not extracted the bug of testcase -' +
                   str(exp_testcase_id))