Example #1
0
def generate_data(project_name, check_trace=True):
    if not project_name in settings.projects:
        return
    git_url, jira_url = settings.projects.get(project_name)
    if check_trace:
        out_path = os.path.join(settings.DATA_DIR, project_name)
    else:
        out_path = os.path.join(settings.NON_TRACE_DIR, project_name)
    if os.path.exists(out_path):
        return
    set_up(git_url, jira_url)
    extractor = JiraExtractor(repo_dir=repo.working_dir,
                              jira_url=jira_url,
                              branch_inspected=branch_inspected,
                              issue_key=None,
                              query=None,
                              commit=None)
    commits = []
    for candidate in extractor.extract_possible_bugs(check_trace=check_trace):
        hexsha = repo.commit(candidate.fix_commit).hexsha
        commits.append(hexsha)
    with open(out_path, "wb") as f:
        json.dump(commits, f)

    return commits
Example #2
0
def execute(git_url, jira_url, specific_commit, check_trace=True):
    bug_data_set = []
    extractor = JiraExtractor(repo_dir=repo.working_dir,
                              jira_url=jira_url,
                              branch_inspected=branch_inspected,
                              commit=specific_commit)
    for candidate in extractor.extract_possible_bugs(check_trace=check_trace):
        try:
            bugs = extract_bugs(candidate, check_trace)
            bug_data_handler.add_bugs(bugs)
        except mvn_bug.BugError as e:
            logging.info('BUG ERROR  ' + e.msg + '\n' + traceback.format_exc())
        except TestObjects.TestParserException as e:
            logging.info('TEST PARSER ERROR  ' + e.msg + '\n' +
                         traceback.format_exc())
        except git.exc.GitCommandError as e:
            logging.info('SHOULD NOT HAPPEN GIT ' + str(e) + '\n' +
                         traceback.format_exc())
            logging.info('Resetting repos')
            reset_repos(git_url, jira_url, specific_commit)
        except Exception as e:
            if 'IOError: [Errno 22]' in e.message:
                logging.info('SHOULD NOT HAPPEN EXCEPTION ' + str(e) + '\n' +
                             traceback.format_exc())
                logging.info('Resetting repos')
                reset_repos(git_url, jira_url, specific_commit)
            else:
                logging.info('SHOULD NOT HAPPEN EXCEPTION ' + str(e) + '\n' +
                             traceback.format_exc())
Example #3
0
 def test_issue_and_commit(self):
     if os.path.exists(os.path.join(os.getcwd(), 'results')):
         time.sleep(5)
         shutil.rmtree(os.path.join(os.getcwd(), 'results'),
                       ignore_errors=True)
     Main.USE_CACHE = False
     Main.GENERATE_DATA = True
     Main.GENERATE_TESTS = True
     Main.USE_CACHED_STATE = False
     Main.TESTS_GEN_STRATEGY = Main.TestGenerationStrategy.CMD
     github = 'https://github.com/apache/commons-math'
     issue_tracker = 'http:\issues.apache.org\jira\projects\MATH'
     Main.set_up(['', github])
     i = 0
     for issue_key, commit_h in zip(['MATH-255', 'MATH-258'], [
             '22d13e12320f2d878880eba50a5bcdc48aa63cc3',
             '9f0ea4e9c43295713c1fc422a1b40b15e902d665'
     ]):
         extractor = JiraExtractor(repo_dir=Main.repo.working_dir,
                                   branch_inspected=Main.branch_inspected,
                                   jira_url=issue_tracker,
                                   issue_key=issue_key)
         Main.mvn_repo.clean()
         # try:
         # 	if i ==0:
         # 		Main.reset_repos(['', github])
         # 		i+=1
         # 		continue
         # 	Main.repo.git.add('.')
         # except git.exc.GitCommandError as e:
         # 	Main.reset_repos(['', github])
         # 	continue
         Main.repo.git.checkout(commit_h, '-f')
         k = extractor.extract_possible_bugs()
         bug = filter(lambda x: commit_h in x.fix_commit,
                      extractor.extract_possible_bugs())[0]
         bug_commit = Main.repo.commit(bug.fix_commit)
         Main.USE_CACHED_STATE = not Main.USE_CACHED_STATE
         bugs = Main.extract_bugs(bug.issue, bug_commit, bug.tests,
                                  bug.diffed_components)
     x = 1