Skip to content

Commit

Permalink
Merge pull request #192 from barbosamaatheus/master
Browse files Browse the repository at this point in the history
feat: support csv with entrypoints column
  • Loading branch information
pauloborba authored Jun 11, 2024
2 parents 0219e1a + 3a52fd1 commit ea1165e
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
results.csv
/data/
/output/
*.iml
/bin/
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,7 @@ One can run the framework tests by running the check task:
`./gradlew check`

* To create new tests, you have to create a git repository with a merge scenario simulating a specific situation you want to test, add it to the `test_repositories` directory, add a corresponding entry to `src/test/input.csv`, and then create the Test class.

## Building

`.\gradlew build -x test`
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class GenerateSootInputFilesOutputProcessor implements OutputProcessor {
* Assumes the path to the script parse_to_soot.py as the 'scripts' directory in the root of the project.
*/
public GenerateSootInputFilesOutputProcessor() {
this("./scripts/" + PARSE_TO_SOOT_FILENAME);
this("./scripts");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,15 @@ class ConflictDetectionAlgorithm {
println "Running ${toString()}"
String filePath = scenario.getLinesFilePath()
String classPath = scenario.getClassPath()
String entrypoints = scenario.getEntrypoints()

return runAndReportResult(filePath, classPath);
return runAndReportResult(filePath, classPath, entrypoints);
} catch (ClassNotFoundInJarException e) {
return "not-found"
}
}

private String runAndReportResult (String filePath, String classPath) {
private String runAndReportResult (String filePath, String classPath, String entrypoints) {
String result;
println "Using jar at " + classPath

Expand All @@ -74,7 +75,7 @@ class ConflictDetectionAlgorithm {
return "false";
}

Process sootProcess = sootWrapper.executeSoot(filePath, classPath, this.mode);
Process sootProcess = sootWrapper.executeSoot(filePath, classPath, this.mode, entrypoints);

// this is needed because if th waitFor command is called without reading the output
// in some executions the output buffer might get full and block the process
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ class NonCommutativeConflictDetectionAlgorithm extends ConflictDetectionAlgorith
String filePath = scenario.getLinesFilePath()
String classPath = scenario.getClassPath()
String filePathReverse = scenario.getLinesReverseFilePath()
String entrypoints = scenario.getEntrypoints()

println "Running left right " + toString();
String leftRightResult = super.runAndReportResult(filePath, classPath)
String leftRightResult = super.runAndReportResult(filePath, classPath, entrypoints)
println "Running right left " + toString();
String rightLeftResult = super.runAndReportResult(filePathReverse, classPath)
String rightLeftResult = super.runAndReportResult(filePathReverse, classPath, entrypoints)

return "${leftRightResult};${rightLeftResult}";
} catch (ClassNotFoundInJarException e) {
Expand Down
8 changes: 7 additions & 1 deletion src/main/services/outputProcessors/soot/Scenario.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ class Scenario {
private String methodSignature;
private String commitSHA;
private boolean hasBuild;
private String entrypoints;

private String scenarioDirectory;

Scenario(projectName, className, methodSignature, commitSHA, scenarioDirectory, hasBuild) {
Scenario(projectName, className, methodSignature, commitSHA, scenarioDirectory, hasBuild, String entrypoints) {
this.projectName = projectName;
this.className = className;
this.methodSignature = methodSignature;
this.commitSHA = commitSHA;
this.scenarioDirectory = scenarioDirectory;
this.hasBuild = hasBuild;
this.entrypoints = entrypoints;
}

boolean getHasBuild() {
Expand Down Expand Up @@ -54,6 +56,10 @@ class Scenario {
return buildJarPath
}

String getEntrypoints() {
return entrypoints
}

private String getJarThatHasClass(File[] buildJars) {
File resultJar = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ScenarioReader {
String classPathName = line["className"]
String methodSignature = line["method"]
String commitSHA = line["merge commit"]
String entrypoints = line["entrypoints"]

String scenarioDirectory = getScenarioDirectory(outputPath, projectName, commitSHA)

Expand All @@ -27,7 +28,7 @@ class ScenarioReader {

boolean hasBuild = line["has_build"] == "true"

def scenario = new Scenario(projectName, classPathName, methodSignature, commitSHA, scenarioDirectory, hasBuild);
def scenario = new Scenario(projectName, classPathName, methodSignature, commitSHA, scenarioDirectory, hasBuild, entrypoints);

result.add(scenario)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ class SootAnalysisWrapper {
this.dependenciesPath = dependenciesPath;
}

Process executeSoot(String inputFilePath, String classPath, String mode) {
Process executeSoot(String inputFilePath, String classPath, String mode, String entrypoints) {
return ProcessRunner.runProcess(".",
"java", "-jar" , getJarPath(),
"-csv", inputFilePath,
"-cp", classPath,
"-mode", mode);
"-mode", mode,
"-entrypoints", entrypoints
);
}

String getSootAnalysisVersionDisclaimer() {
Expand Down

0 comments on commit ea1165e

Please sign in to comment.