Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set up cf-691 to use --targetField #42

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Keyvalue.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class JsonKeys(Enum):
PACKAGE = 'package'
TARGETS = 'targets'
METHOD_NAME = 'method'
FIELD_NAME = 'field'
FILE_NAME = 'file'
CF_Version = 'cf_version'
JAVA_VERSION = 'java_version'
Expand Down
22 changes: 16 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def build_specimin_command(project_name: str,
project_name (str): Name of the target project. Example: daikon
target_base_dir (str): path of the target project directory. Ex: ISSUES/cf-1291
root_dir (str): A directory path relative to the project base directory where java package stored.
targets ({'method': '', 'file': '', 'package': ''}) : target java file and method name data
targets ({'method': '' or 'field': '', 'file': '', 'package': ''}) : target java file and method/field name data

Retruns:
command (str): The gradle command of SPECIMIN for the issue.
Expand All @@ -294,10 +294,12 @@ def build_specimin_command(project_name: str,

target_file_list = []
target_method_list = []
target_field_list = []

for target in targets:

method_name = target[JsonKeys.METHOD_NAME.value]
field_name = target.get(JsonKeys.FIELD_NAME.value)
file_name = target[JsonKeys.FILE_NAME.value]
package_name = target[JsonKeys.PACKAGE.value]

Expand All @@ -307,10 +309,11 @@ def build_specimin_command(project_name: str,
qualified_file_name = os.path.join(dot_replaced_package_name, file_name)
target_file_list.append(qualified_file_name)

inner_class_name = ""
if JsonKeys.INNER_CLASS.value in target and target[JsonKeys.INNER_CLASS.value] :
inner_class_name = f".{target[JsonKeys.INNER_CLASS.value]}"

if method_name:
inner_class_name = ""
if JsonKeys.INNER_CLASS.value in target and target[JsonKeys.INNER_CLASS.value] :
inner_class_name = f".{target[JsonKeys.INNER_CLASS.value]}"
#if non-primary class exists, file name will not be included in target-method
# Look for PR #177: https://github.com/kelloggm/specimin/pull/177

Expand All @@ -320,6 +323,9 @@ def build_specimin_command(project_name: str,
qualified_method_name = package_name + "." + os.path.splitext(file_name)[0]+ inner_class_name + "#" + method_name
target_method_list.append(qualified_method_name)

if field_name:
target_field_list.append(package_name + "." + os.path.splitext(file_name)[0]+ inner_class_name + "#" + field_name)

output_dir_subcommand = "--outputDirectory" + " " + f"\"{output_dir}\""
root_dir_subcommand = "--root" + " " + f"\"{root_dir}\""
target_file_subcommand = ""
Expand All @@ -329,12 +335,16 @@ def build_specimin_command(project_name: str,
target_method_subcommand = ""
for method in target_method_list:
target_method_subcommand += "--targetMethod" + " " + f"\"{method}\""


target_field_subcommand = ""
for field in target_field_list:
target_field_subcommand += " --targetField" + " " + f"\"{field}\""

jar_path_subcommand = ""
if jar_path:
jar_path_subcommand = " --jarPath" + " " + f"\"{jar_path}\""

command_args = root_dir_subcommand + " " + output_dir_subcommand + " " + target_file_subcommand + " " + target_method_subcommand + jar_path_subcommand
command_args = root_dir_subcommand + " " + output_dir_subcommand + " " + target_file_subcommand + " " + target_method_subcommand + target_field_subcommand + jar_path_subcommand
command = "./gradlew" + " " + "run" + " " + "--args=" + f"\'{command_args}\'"

return command
Expand Down
6 changes: 4 additions & 2 deletions resources/test_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,11 @@
"root_dir": "",
"targets": [
{
"method": "sort(List<T>)",
"method": "",
"field": "EMPTY_NAVIGABLE_SET",
"file": "Collections.java",
"package": "com.example"
"package": "com.example",
"inner_class": "UnmodifiableNavigableSet"
}
],
"cf_version": "1.9.13",
Expand Down
Loading