Testing.
This commit is contained in:
+6
-7
@@ -68,9 +68,8 @@ public class FixedViolationHunkParser extends FixedViolationParser {
|
|||||||
for (Violation v : violations) {
|
for (Violation v : violations) {
|
||||||
System.err.println(type + revFile.getName().replace("#", "/") + ":" + v.getStartLineNum() + ":" + v.getEndLineNum() + ":" + v.getAlarmType());
|
System.err.println(type + revFile.getName().replace("#", "/") + ":" + v.getStartLineNum() + ":" + v.getEndLineNum() + ":" + v.getAlarmType());
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
// }
|
|
||||||
// if (actionSets != null && actionSets.size() != 0) {
|
|
||||||
if (violations.size() == 0) {
|
if (violations.size() == 0) {
|
||||||
this.resultType = 4;
|
this.resultType = 4;
|
||||||
return;
|
return;
|
||||||
@@ -197,7 +196,7 @@ public class FixedViolationHunkParser extends FixedViolationParser {
|
|||||||
if (fixStartLine == 0) {
|
if (fixStartLine == 0) {
|
||||||
// pure delete actions.
|
// pure delete actions.
|
||||||
this.pureDeletions ++;
|
this.pureDeletions ++;
|
||||||
System.err.println("#PureDeletion: " + revFile.getName().replace("#", "/") + ":" + violation.getStartLineNum()
|
System.err.println("#PureDeletion:" + revFile.getName().replace("#", "/") + ":" + violation.getStartLineNum()
|
||||||
+ ":" + violation.getEndLineNum() + ":" + violation.getAlarmType());
|
+ ":" + violation.getEndLineNum() + ":" + violation.getAlarmType());
|
||||||
// continue;
|
// continue;
|
||||||
}
|
}
|
||||||
@@ -221,8 +220,8 @@ public class FixedViolationHunkParser extends FixedViolationParser {
|
|||||||
// continue;
|
// continue;
|
||||||
}
|
}
|
||||||
if (bugEndLine - bugStartLine > Configuration.HUNK_SIZE || fixEndLine - fixStartLine > Configuration.HUNK_SIZE) {
|
if (bugEndLine - bugStartLine > Configuration.HUNK_SIZE || fixEndLine - fixStartLine > Configuration.HUNK_SIZE) {
|
||||||
this.largeHunk ++;
|
|
||||||
if (fixStartLine != 0) {
|
if (fixStartLine != 0) {
|
||||||
|
this.largeHunk ++;
|
||||||
System.err.println("#LargeHunk:" + revFile.getName().replace("#", "/") + ":" + violation.getStartLineNum()
|
System.err.println("#LargeHunk:" + revFile.getName().replace("#", "/") + ":" + violation.getStartLineNum()
|
||||||
+ ":" + violation.getEndLineNum() + ":" + violation.getAlarmType());
|
+ ":" + violation.getEndLineNum() + ":" + violation.getAlarmType());
|
||||||
}
|
}
|
||||||
@@ -235,8 +234,8 @@ public class FixedViolationHunkParser extends FixedViolationParser {
|
|||||||
// Source Code of patches.
|
// Source Code of patches.
|
||||||
String patchSourceCode = getPatchSourceCode(prevFile, revFile, bugStartLine, bugEndLine, fixStartLine, fixEndLine, isInsert);
|
String patchSourceCode = getPatchSourceCode(prevFile, revFile, bugStartLine, bugEndLine, fixStartLine, fixEndLine, isInsert);
|
||||||
if ("".equals(patchSourceCode)) {
|
if ("".equals(patchSourceCode)) {
|
||||||
this.nullSourceCode ++;
|
|
||||||
if (fixStartLine != 0) {
|
if (fixStartLine != 0) {
|
||||||
|
this.nullSourceCode ++;
|
||||||
System.err.println("#NullSourceCode:" + revFile.getName().replace("#", "/") + ":" + violation.getStartLineNum()
|
System.err.println("#NullSourceCode:" + revFile.getName().replace("#", "/") + ":" + violation.getStartLineNum()
|
||||||
+ ":" + violation.getEndLineNum() + ":" + violation.getAlarmType());
|
+ ":" + violation.getEndLineNum() + ":" + violation.getAlarmType());
|
||||||
}
|
}
|
||||||
@@ -270,8 +269,8 @@ public class FixedViolationHunkParser extends FixedViolationParser {
|
|||||||
if (!"SE_NO_SERIALVERSIONID".equals(alarmType)) {
|
if (!"SE_NO_SERIALVERSIONID".equals(alarmType)) {
|
||||||
if (containsFiledDeclaration(hunkActionSets)) {
|
if (containsFiledDeclaration(hunkActionSets)) {
|
||||||
// this.nullMappingGumTreeResult ++; //TODO
|
// this.nullMappingGumTreeResult ++; //TODO
|
||||||
this.testingInfo += info + revFile.getName() + "\n";
|
|
||||||
if (fixStartLine != 0) {
|
if (fixStartLine != 0) {
|
||||||
|
this.testingInfo += info + revFile.getName() + "\n";
|
||||||
this.testingInfo += "#TestingInfo: " + revFile.getName().replace("#", "/") + ":" + violation.getStartLineNum()
|
this.testingInfo += "#TestingInfo: " + revFile.getName().replace("#", "/") + ":" + violation.getStartLineNum()
|
||||||
+ ":" + violation.getEndLineNum() + ":" + violation.getAlarmType();
|
+ ":" + violation.getEndLineNum() + ":" + violation.getAlarmType();
|
||||||
}
|
}
|
||||||
@@ -293,8 +292,8 @@ public class FixedViolationHunkParser extends FixedViolationParser {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// this.nullMappingGumTreeResult ++; // TODO
|
// this.nullMappingGumTreeResult ++; // TODO
|
||||||
this.testingInfo += info + revFile.getName() + "\n";
|
|
||||||
if (fixStartLine != 0) {
|
if (fixStartLine != 0) {
|
||||||
|
this.testingInfo += info + revFile.getName() + "\n";
|
||||||
this.testingInfo += "#TestingInfo: " + revFile.getName().replace("#", "/") + ":" + violation.getStartLineNum()
|
this.testingInfo += "#TestingInfo: " + revFile.getName().replace("#", "/") + ":" + violation.getStartLineNum()
|
||||||
+ ":" + violation.getEndLineNum() + ":" + violation.getAlarmType();
|
+ ":" + violation.getEndLineNum() + ":" + violation.getAlarmType();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,6 @@ import java.io.StringReader;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.github.gumtreediff.actions.model.Action;
|
import com.github.gumtreediff.actions.model.Action;
|
||||||
|
|
||||||
import edu.lu.uni.serval.FixPatternParser.Parser;
|
import edu.lu.uni.serval.FixPatternParser.Parser;
|
||||||
@@ -27,8 +24,6 @@ import edu.lu.uni.serval.utils.ListSorter;
|
|||||||
*/
|
*/
|
||||||
public class FixedViolationParser extends Parser {
|
public class FixedViolationParser extends Parser {
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(FixedViolationParser.class);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ResultType:
|
* ResultType:
|
||||||
* 0: normal GumTree results.
|
* 0: normal GumTree results.
|
||||||
|
|||||||
@@ -83,15 +83,18 @@ public class ParseFixPatternWorker extends UntypedActor {
|
|||||||
int largeHunk = 0;
|
int largeHunk = 0;
|
||||||
int nullSourceCode = 0;
|
int nullSourceCode = 0;
|
||||||
int illegalV = 0;
|
int illegalV = 0;
|
||||||
|
|
||||||
|
// Read violations with Null_Violation_Hunk or Illegal_Line_Position
|
||||||
|
List<Violation> uselessViolations = readUselessViolations("logs/FixedViolationCodeParseResults.log");
|
||||||
|
|
||||||
for (MessageFile msgFile : files) {
|
for (MessageFile msgFile : files) {
|
||||||
File revFile = msgFile.getRevFile();
|
File revFile = msgFile.getRevFile();
|
||||||
File prevFile = msgFile.getPrevFile();
|
File prevFile = msgFile.getPrevFile();
|
||||||
File diffentryFile = msgFile.getDiffEntryFile();
|
File diffentryFile = msgFile.getDiffEntryFile();
|
||||||
File positionFile = msgFile.getPositionFile();
|
File positionFile = msgFile.getPositionFile();
|
||||||
if (revFile.getName().toLowerCase().contains("test")) {
|
if (revFile.getName().toLowerCase().contains("/test/")) {
|
||||||
testAlarms += countAlarms(positionFile, "#TestViolation:");
|
testAlarms += countAlarms(positionFile, "#TestViolation:", uselessViolations);
|
||||||
// continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Parser parser = null;
|
// Parser parser = null;
|
||||||
// if (containsAlarmTypes || positionFile != null) {
|
// if (containsAlarmTypes || positionFile != null) {
|
||||||
@@ -101,8 +104,6 @@ public class ParseFixPatternWorker extends UntypedActor {
|
|||||||
// parser = new CommitPatchSingleStatementParser();
|
// parser = new CommitPatchSingleStatementParser();
|
||||||
// }
|
// }
|
||||||
FixedViolationHunkParser parser = new FixedViolationHunkParser(positionFile);
|
FixedViolationHunkParser parser = new FixedViolationHunkParser(positionFile);
|
||||||
// Read violations with Null_Violation_Hunk or Illegal_Line_Position
|
|
||||||
List<Violation> uselessViolations = readUselessViolations("logs/FixedViolationCodeParseResults.log");
|
|
||||||
parser.setUselessViolations(uselessViolations);
|
parser.setUselessViolations(uselessViolations);
|
||||||
|
|
||||||
final ExecutorService executor = Executors.newSingleThreadExecutor();
|
final ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
@@ -121,14 +122,14 @@ public class ParseFixPatternWorker extends UntypedActor {
|
|||||||
String editScript = parser.getAstEditScripts();
|
String editScript = parser.getAstEditScripts();
|
||||||
if ("".equals(editScript)) {
|
if ("".equals(editScript)) {
|
||||||
if (parser.resultType == 1) {
|
if (parser.resultType == 1) {
|
||||||
nullGumTreeResults += countAlarms(positionFile, "");
|
nullGumTreeResults += countAlarms(positionFile, "", uselessViolations);
|
||||||
// System.err.println("#NullGumTreeResult:" + revFile.getName());
|
// System.err.println("#NullGumTreeResult:" + revFile.getName());
|
||||||
} else if (parser.resultType == 2) {
|
} else if (parser.resultType == 2) {
|
||||||
noSourceCodeChanges += countAlarms(positionFile, "");
|
noSourceCodeChanges += countAlarms(positionFile, "", uselessViolations);
|
||||||
} else if (parser.resultType == 3) {
|
} else if (parser.resultType == 3) {
|
||||||
noStatementChanges += countAlarms(positionFile, "");
|
noStatementChanges += countAlarms(positionFile, "", uselessViolations);
|
||||||
} else if (parser.resultType == 4) {
|
} else if (parser.resultType == 4) {
|
||||||
illegalV += countAlarms(positionFile, "");
|
// illegalV += countAlarms(positionFile, "", uselessViolations);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
editScripts.append(editScript);
|
editScripts.append(editScript);
|
||||||
@@ -158,14 +159,14 @@ public class ParseFixPatternWorker extends UntypedActor {
|
|||||||
} catch (TimeoutException e) {
|
} catch (TimeoutException e) {
|
||||||
// err.println("task timed out");
|
// err.println("task timed out");
|
||||||
future.cancel(true);
|
future.cancel(true);
|
||||||
expNums += countAlarms(positionFile, "#Timeout:");
|
expNums += countAlarms(positionFile, "#Timeout:", uselessViolations);
|
||||||
// System.err.println("#Timeout: " + revFile.getName());
|
// System.err.println("#Timeout: " + revFile.getName());
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
expNums += countAlarms(positionFile, "#TimeInterrupted:");
|
expNums += countAlarms(positionFile, "#TimeInterrupted:", uselessViolations);
|
||||||
// err.println("task interrupted");
|
// err.println("task interrupted");
|
||||||
// System.err.println("#TimeInterrupted: " + revFile.getName());
|
// System.err.println("#TimeInterrupted: " + revFile.getName());
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
expNums += countAlarms(positionFile, "#TimeAborted:");
|
expNums += countAlarms(positionFile, "#TimeAborted:", uselessViolations);
|
||||||
// err.println("task aborted");
|
// err.println("task aborted");
|
||||||
// System.err.println("#TimeAborted: " + revFile.getName());
|
// System.err.println("#TimeAborted: " + revFile.getName());
|
||||||
} finally {
|
} finally {
|
||||||
@@ -233,17 +234,25 @@ public class ParseFixPatternWorker extends UntypedActor {
|
|||||||
return uselessViolations;
|
return uselessViolations;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int countAlarms(File positionFile, String type) {
|
private int countAlarms(File positionFile, String type, List<Violation> uselessViolations) {
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
String content = FileHelper.readFile(positionFile);
|
String content = FileHelper.readFile(positionFile);
|
||||||
BufferedReader reader = new BufferedReader(new StringReader(content));
|
BufferedReader reader = new BufferedReader(new StringReader(content));
|
||||||
String line = null;
|
String line = null;
|
||||||
try {
|
try {
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
counter ++;
|
String[] elements = line.split(":");
|
||||||
if (!"".equals(type)) {
|
Violation v = new Violation(Integer.parseInt(elements[1]), Integer.parseInt(elements[2]), elements[0]);
|
||||||
String[] elements = line.split(":");
|
String fileName = positionFile.getName().replaceAll("#", "/").replace(".txt", ".java");
|
||||||
System.err.println(type + positionFile.getName().replaceAll("#", "/").replace(".txt", ".java") + ":" + elements[1] + ":" + elements[2] + ":" + elements[0]);
|
v.setFileName(fileName);
|
||||||
|
if (!uselessViolations.contains(v)) {
|
||||||
|
counter ++;
|
||||||
|
|
||||||
|
if (!"".equals(type)) {
|
||||||
|
if (!uselessViolations.contains(v)) {
|
||||||
|
System.err.println(type + fileName + ":" + elements[1] + ":" + elements[2] + ":" + elements[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package edu.lu.uni.serval.config;
|
|||||||
|
|
||||||
public class Configuration {
|
public class Configuration {
|
||||||
|
|
||||||
public static final long SECONDS_TO_WAIT = 60L;
|
public static final long SECONDS_TO_WAIT = 120L;
|
||||||
|
|
||||||
public static final String ROOT_PATH = "../FPM_Violations/"; // The root path of all output data.
|
public static final String ROOT_PATH = "../FPM_Violations/"; // The root path of all output data.
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,9 @@ public class Statistic {
|
|||||||
int largeHunk = 0;
|
int largeHunk = 0;
|
||||||
int nullSourceCode = 0;
|
int nullSourceCode = 0;
|
||||||
int noStatementChanges = 0;
|
int noStatementChanges = 0;
|
||||||
|
int IllegalV = 0;
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
|
if (file.getName().startsWith("test")) continue;
|
||||||
String content = FileHelper.readFile(file);
|
String content = FileHelper.readFile(file);
|
||||||
BufferedReader reader = new BufferedReader(new StringReader(content));
|
BufferedReader reader = new BufferedReader(new StringReader(content));
|
||||||
String line = null;
|
String line = null;
|
||||||
@@ -88,6 +90,8 @@ public class Statistic {
|
|||||||
nullSourceCode += Integer.parseInt(line.substring(line.lastIndexOf(":") + 1).trim());
|
nullSourceCode += Integer.parseInt(line.substring(line.lastIndexOf(":") + 1).trim());
|
||||||
} else if (line.startsWith("noStatementChanges")) {
|
} else if (line.startsWith("noStatementChanges")) {
|
||||||
noStatementChanges += Integer.parseInt(line.substring(line.lastIndexOf(":") + 1).trim());
|
noStatementChanges += Integer.parseInt(line.substring(line.lastIndexOf(":") + 1).trim());
|
||||||
|
} else if (line.startsWith("IllegalV")) {
|
||||||
|
IllegalV +=Integer.parseInt(line.substring(line.lastIndexOf(":") + 1).trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -110,12 +114,14 @@ public class Statistic {
|
|||||||
// Statistics:
|
// Statistics:
|
||||||
// TestAlarms: 5696
|
// TestAlarms: 5696
|
||||||
// nullGumTreeResults: 0
|
// nullGumTreeResults: 0
|
||||||
// nullMappingGumTreeResults: 26366
|
// nullMappingGumTreeResults: 29056 29078
|
||||||
// pureDeletion: 38158
|
// pureDeletion: 40728
|
||||||
// Timeout: 6090
|
// Timeout: 135
|
||||||
// noSourceCodeChange: 14442
|
// noSourceCodeChange: 7496
|
||||||
// largeHunk: 232
|
// largeHunk: 2584
|
||||||
// nullSourceCode: 0
|
// nullSourceCode: 0
|
||||||
|
// noStatementChanges: 7567
|
||||||
|
// IllegalV: 1194
|
||||||
System.out.println("\n\nStatistics:\nTestAlarms: " + testAlarms);
|
System.out.println("\n\nStatistics:\nTestAlarms: " + testAlarms);
|
||||||
System.out.println("nullGumTreeResults: " + nullGumTreeResults);
|
System.out.println("nullGumTreeResults: " + nullGumTreeResults);
|
||||||
System.out.println("nullMappingGumTreeResults: " + nullMappingGumTreeResults);
|
System.out.println("nullMappingGumTreeResults: " + nullMappingGumTreeResults);
|
||||||
@@ -125,6 +131,7 @@ public class Statistic {
|
|||||||
System.out.println("largeHunk: " + largeHunk);
|
System.out.println("largeHunk: " + largeHunk);
|
||||||
System.out.println("nullSourceCode: " + nullSourceCode);
|
System.out.println("nullSourceCode: " + nullSourceCode);
|
||||||
System.out.println("noStatementChanges: " + noStatementChanges);
|
System.out.println("noStatementChanges: " + noStatementChanges);
|
||||||
|
System.out.println("IllegalV: " + IllegalV);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void statistics(String fileName, String type) throws IOException {
|
public static void statistics(String fileName, String type) throws IOException {
|
||||||
|
|||||||
Reference in New Issue
Block a user