-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOwningFieldModifier.py
More file actions
35 lines (31 loc) · 1.47 KB
/
OwningFieldModifier.py
File metadata and controls
35 lines (31 loc) · 1.47 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
import subprocess
import os
import logging
from utils import compute_p_flag
from Constants import OWNING_FIELD_JAR
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s %(levelname)s: %(message)s",
datefmt="%Y-%m-%d %H:%M:%S"
)
def run_owning_field_plugin(log_file_path, source_project_path):
logging.info("Invoking Owning Field Modifier plugin...")
try:
subprocess.run([
"java", "-jar", OWNING_FIELD_JAR,
"--log", log_file_path,
"--project-root", source_project_path
], check=True)
except subprocess.CalledProcessError as e:
logging.error(f"Plugin execution failed: {e}")
return False
patch_path = os.path.join(source_project_path, "src", "owning-field.patch")
if os.path.exists(patch_path) and os.path.getsize(patch_path) > 0:
logging.info(f"Patch generated at {patch_path}. Applying to benchmark: {source_project_path}")
os.system(f"cd {source_project_path}/src && dos2unix owning-field.patch > /dev/null 2>&1")
patch_command = f"cd {source_project_path}/src/ && patch --forward -p{compute_p_flag(source_project_path + '/src/owning-field.patch')} -u -F3 --ignore-whitespace -i owning-field.patch"
os.system(patch_command)
def check_for_owning_patch(benchmark_path):
"""Check if a patch was generated by the Close Injector."""
patch_file = f"{benchmark_path}/src/owning-field.patch"
return os.path.exists(patch_file) and os.path.getsize(patch_file) > 0