-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
executable file
·93 lines (75 loc) · 3.46 KB
/
run.py
File metadata and controls
executable file
·93 lines (75 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import argparse
import json
import os
import pickle
import shutil
import sys
from Evaluation.evaluate import evaluate
from functions.d4j import check_out, get_failed_tests, get_properties
from functions.sbfl import parse_sbfl, parse_sbfl_version_2
from preprocess.read_nodes import get_methods_for_sbfl
from Utils.path_manager import PathManager
root = os.path.dirname(__file__)
sys.path.append(root)
def main():
parser = argparse.ArgumentParser(description='argparse')
parser.add_argument('--config', type=str, default="default",
help="Name of config, which is used to load configuration under Config/")
parser.add_argument('--version', type=str, default="GrowingBugs",
help="Version of defects4j")
parser.add_argument('--project', type=str, default="AaltoXml",
help="Name of project, your debug result will be generated in DebugResult/d4jversion_project_bugID")
parser.add_argument('--bugID', type=int, default=1,
help="Prompt of software")
parser.add_argument('--subproj', type=str, required=False, default="",
help="The subproject of the project")
parser.add_argument('-c', '--clear', type=bool, default=True,
help="If clear the checkout project")
args = parser.parse_args()
# ----------------------------------------
# Init Test Failure
# ----------------------------------------
path_manager = PathManager(args)
path_manager.logger.info("*" * 100)
path_manager.logger.info(f"Start debugging bug {args.version}-{args.project}-{args.bugID}")
bug_name = f"{args.project}-{args.bugID}"
if os.path.exists(path_manager.res_file):
path_manager.logger.info(f"d4j{args.version}-{args.project}-{args.bugID} already finished, skip!")
return
# check out the d4j project
# path_manager.logger.info("[checkout] start...")
# check_out(path_manager)
# get cahed buggy method information
path_manager.logger.info("[get buggy method infos] start...")
with open(path_manager.buggy_methods_file, "r") as f:
buggy_methods = json.load(f)
if bug_name not in buggy_methods:
path_manager.logger.error(f"Bug {bug_name} not found in the buggy methods cached file")
return
# get bug specific information
# path_manager.logger.info("[get bug properties] start...")
# get_properties(path_manager)
# ----------------------------------------
# SBFL results
# ----------------------------------------
sbfl_res = None
sbfl_res = parse_sbfl_version_2(path_manager.sbfl_file)
if len(sbfl_res) == 0:
path_manager.logger.error(f"Empty SBFL results in {path_manager.sbfl_file}")
return
# ----------------------------------------
# Load Index
# ----------------------------------------
# path_manager.logger.info("[load data] start...")
# nodes = get_methods_for_sbfl(path_manager, sbfl_res)
# with open(path_manager.retrieved_nodes_file, "wb") as f:
# pickle.dump(nodes, f)
# ----------------------------------------
# Evaluate
# ----------------------------------------
evaluate(path_manager, sbfl_res, buggy_methods)
if args.clear:
shutil.rmtree(path_manager.buggy_path, ignore_errors=True)
shutil.rmtree(path_manager.fixed_path, ignore_errors=True)
if __name__ == "__main__":
main()