Skip to content

Commit

Permalink
Merge pull request #9 from njit-jerse/mm
Browse files Browse the repository at this point in the history
Add modularity model logic
  • Loading branch information
kelloggm authored Jul 30, 2024
2 parents ae99754 + c4c97f9 commit 7aa539c
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 42 deletions.
1 change: 1 addition & 0 deletions Keyvalue.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ class JsonKeys(Enum):
BUG_TYPE = 'bug_type'
CHECKER_QUAL_REQURIED = 'checker_qual_required'
BUG_PATTERN = 'bug_pattern'
MODEL = 'model'
13 changes: 9 additions & 4 deletions TestMain.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,28 +61,32 @@ def test_build_specimin_command(self):
targets = [{
"method": "getMode(ColumnMetadata, Map<String, String>)",
"file": "IndexMode.java",
"package": 'org.apache.cassandra.index.sasi.conf'
"package": 'org.apache.cassandra.index.sasi.conf',
"model": "cf"
}]

target_dir = '/user/ISSUES/cf-6077'
command = main.build_specimin_command(proj_name, target_dir, root, targets)
target_command = ''
with open('resources/specimin_command_cf-6077.txt','r') as file:
target_command = file.read()
target_command = target_command.strip()
self.assertEqual(command, target_command)
# not executing since this crashes specimin
proj_name = 'kafka-sensors'
root = 'src/main/java/'
targets = [{
"method": "transform(String, byte[])",
"file": "Avro2Confluent.java",
"package": 'com.fillmore_labs.kafka.sensors.serde.confluent.interop'
"package": 'com.fillmore_labs.kafka.sensors.serde.confluent.interop',
"model" : "cf"
}]

target_dir = '/user/ISSUES/cf-6019'
command = main.build_specimin_command(proj_name, target_dir, root, targets)
with open('resources/specimin_command_cf-6019.txt','r') as file:
target_command = file.read()
target_command = target_command.strip()
self.assertEqual(command, target_command)
#not executing since it crashes specimin.

Expand All @@ -109,7 +113,8 @@ def test_run_specimin(self):
targets = [{
"method": "bar()",
"file": "Simple.java",
"package": "com.example"
"package": "com.example",
"model" : "cf"
}]
target_dir = 'resources/onefilesimple'

Expand All @@ -121,4 +126,4 @@ def test_run_specimin(self):


if __name__ == '__main__':
unittest.main()
unittest.main()
9 changes: 7 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,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': '' or 'field': '', 'file': '', 'package': ''}) : target java file and method/field name data
targets ({'method': '' or 'field': '', 'file': '', 'package': '', 'model' : ''}) : target java file, modularity model, and method/field name data
Retruns:
command (str): The gradle command of SPECIMIN for the issue.
Expand Down Expand Up @@ -335,6 +335,7 @@ def build_specimin_command(project_name: str,
field_name = target.get(JsonKeys.FIELD_NAME.value)
file_name = target[JsonKeys.FILE_NAME.value]
package_name = target[JsonKeys.PACKAGE.value]
modularity_model = target[JsonKeys.MODEL.value]

dot_replaced_package_name = package_name.replace('.', '/')

Expand Down Expand Up @@ -380,7 +381,11 @@ def build_specimin_command(project_name: str,
if jar_path:
jar_path_subcommand = " --jarPath" + " " + f"\"{jar_path}\""

command_args = root_dir_subcommand + " " + output_dir_subcommand + " " + target_file_subcommand + " " + target_method_subcommand + target_field_subcommand + jar_path_subcommand
model_subcommand = ""
if modularity_model:
model_subcommand = " --modularityModel " + f"\"{modularity_model}\""

command_args = root_dir_subcommand + " " + output_dir_subcommand + model_subcommand + " " + target_file_subcommand + " " + target_method_subcommand + target_field_subcommand + jar_path_subcommand


command = ""
Expand Down
2 changes: 1 addition & 1 deletion resources/specimin_command_cf-6019.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
./gradlew run --args='--root "/user/ISSUES/cf-6019/input/kafka-sensors/src/main/java/" --outputDirectory "/user/ISSUES/cf-6019/output/kafka-sensors/src/main/java" --targetFile "com/fillmore_labs/kafka/sensors/serde/confluent/interop/Avro2Confluent.java" --targetMethod "com.fillmore_labs.kafka.sensors.serde.confluent.interop.Avro2Confluent#transform(String, byte[])"'
./gradlew run --args='--root "/user/ISSUES/cf-6019/input/kafka-sensors/src/main/java/" --outputDirectory "/user/ISSUES/cf-6019/output/kafka-sensors/src/main/java" --modularityModel "cf" --targetFile "com/fillmore_labs/kafka/sensors/serde/confluent/interop/Avro2Confluent.java" --targetMethod "com.fillmore_labs.kafka.sensors.serde.confluent.interop.Avro2Confluent#transform(String, byte[])"'
2 changes: 1 addition & 1 deletion resources/specimin_command_cf-6077.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
./gradlew run --args='--root "/user/ISSUES/cf-6077/input/cassandra/src/java/" --outputDirectory "/user/ISSUES/cf-6077/output/cassandra/src/main/java" --targetFile "org/apache/cassandra/index/sasi/conf/IndexMode.java" --targetMethod "org.apache.cassandra.index.sasi.conf.IndexMode#getMode(ColumnMetadata, Map<String, String>)"'
./gradlew run --args='--root "/user/ISSUES/cf-6077/input/cassandra/src/java/" --outputDirectory "/user/ISSUES/cf-6077/output/cassandra/src/main/java" --modularityModel "cf" --targetFile "org/apache/cassandra/index/sasi/conf/IndexMode.java" --targetMethod "org.apache.cassandra.index.sasi.conf.IndexMode#getMode(ColumnMetadata, Map<String, String>)"'
Loading

0 comments on commit 7aa539c

Please sign in to comment.