forked from BugsJS/bug-dataset
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate-metadata.py
63 lines (58 loc) · 1.74 KB
/
generate-metadata.py
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
import json
import os
import shutil
import subprocess
from typing import List, Tuple
x = open("meta-data.json", "w")
projects: List[Tuple[str, int]] = [
("Express", 27),
("Shields", 4),
("Bower", 3),
("Hexo", 12),
("Karma", 22),
("Hessian.js", 9),
("Eslint", 333),
("Node-redis", 7),
("Pencilblue", 7),
("Mongoose", 29),
]
result = []
id = 0
for name, bug_count in projects:
os.makedirs(name, exist_ok=True)
for bug in range(1, bug_count):
os.makedirs(os.path.join(name, f"{name}-{bug}"),exist_ok=True)
for script in ["build_subject","config_subject","setup_subject","test_subject"]:
shutil.copy(script,os.path.join(name, f"{name}-{bug}",script))
id += 1
proc = subprocess.Popen(
["python3 main.py -p {} -b {} -t info -v buggy".format(name, bug)],
stdout=subprocess.PIPE,
shell=True,
)
(out, err) = proc.communicate()
data = out.decode("utf-8")
lines = data.split("\n")
print(data)
result.append(
{
"id": id,
"subject": name,
"bug_id": f"{name}-{bug}",
"test_timeout": 5,
"language": "js",
"build_script": "build_subject",
"config_script": "config_subject",
"clean_script": "clean_subject",
"test_script": "test_subject",
"passing_test_identifiers": [],
"count_pos": 0,
"failing_test_identifiers": [],
"count_neg": 0,
"line_numbers": [],
"dependencies": [],
}
)
# input()
x.write(json.dumps(result, indent=4))
x.close()