Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class DataPreparer {

private String buggyProjectParentPath;

public String bugDir; // the working directory for GZoltar.

public String classPath;
public String srcPath;
public String testClassPath;
Expand Down Expand Up @@ -62,6 +64,8 @@ private void loadPaths(String buggyProject) {
srcPath = projectDir + buggyProject + paths.get(2);
testSrcPath = projectDir + buggyProject + paths.get(3);

bugDir = projectDir + buggyProject; // set bugDir.

List<File> libPackages = new ArrayList<>();// dependencies.
if (new File(projectDir + buggyProject + "/lib/").exists()) {
libPaths.add(projectDir + buggyProject + "/lib/");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public class FL {
public static void main(String[] args) {
String outputPath = "GZoltar-0.1.1/" + Configuration.SUSPICIOUS_POSITIONS_FILE_APTH;
String path = Configuration.BUGGY_PROJECTS_PATH;
String projectName = "Chart_11";

// To run FL for Time_7.
String projectName = "Time_7";

log.info(projectName);

Expand Down Expand Up @@ -73,7 +75,7 @@ public void locateSuspiciousCode(String path, String buggyProject, String output
gzfl.srcPath = path + buggyProject + PathUtils.getSrcPath(buggyProject).get(2);

try {
gzfl.localizeSuspiciousCodeWithGZoltar(dp.classPaths, checkNotNull(Arrays.asList("")), dp.testCases);
gzfl.localizeSuspiciousCodeWithGZoltar(dp.bugDir, dp.classPaths, checkNotNull(Arrays.asList("")), dp.testCases);
} catch (NullPointerException e) {
for (String metricStr : Configuration.METRICS_0_1_1) {
FileHelper.outputToFile(outputPath + buggyProject + "/" + metricStr + ".txt", "", false);
Expand Down Expand Up @@ -136,7 +138,7 @@ public void locateSuspiciousCode(String path, String buggyProject, String output
gzfl.srcPath = path + buggyProject + PathUtils.getSrcPath(buggyProject).get(2);

try {
gzfl.localizeSuspiciousCodeWithGZoltar(dp.classPaths, checkNotNull(Arrays.asList("")), dp.testCases);
gzfl.localizeSuspiciousCodeWithGZoltar(dp.bugDir, dp.classPaths, checkNotNull(Arrays.asList("")), dp.testCases);
} catch (NullPointerException e) {
log.error(buggyProject + "\n" + e.getMessage());
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class GZoltarFaultLoclaization {
public List<String> failingTestCases = new ArrayList<String>();
public ArrayList<Statement> selectedSuspiciousStatements = new ArrayList<>();

public void localizeSuspiciousCodeWithGZoltar(final URL[] clazzPaths, Collection<String> packageNames, String... testClasses) throws NullPointerException {
public void localizeSuspiciousCodeWithGZoltar(String bugDir, final URL[] clazzPaths, Collection<String> packageNames, String... testClasses) throws NullPointerException {
ArrayList<String> classPaths = new ArrayList<String>();
StringBuilder b = new StringBuilder();
for (URL url : clazzPaths) {// Dependencies. lib
Expand All @@ -65,7 +65,13 @@ public void localizeSuspiciousCodeWithGZoltar(final URL[] clazzPaths, Collection
b.setLength(0);

try {
GZoltar gzoltar = new GZoltar(System.getProperty("user.dir"));
// Dale:
// the original code: new GZoltar(System.getProperty("user.dir"))
// will lead to unexpected failed test cases when localizing Time buggy projects,
// (e.g., this leads to the failure of org.joda.time.TestSerialization#testSerializedMutableDateTime when localizing Time_7.
// The failing detail includes: java.io.FileNotFoundException: src/test/resources/MutableDateTime.dat (No such file or directory)
// Therefore, the GZoltar working dir should be the bugDir, rather than the current FL project dir.
GZoltar gzoltar = new GZoltar(bugDir);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try this parameter setting for each Defects4J bug?
I remembered that I tried this parameter, it can throw some unexpected exceptions for some Defects4J bugs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I have only studied the failure exposed by Time_7. In Time_7, it does not throw any exceptions, instead, the failure (i.e., the unexpected failed tests) needs to be examined manually (using Debugging or print statements).

And we can ensure that if GZoltar is not initialized with the buggy program directory, there will be also some Defectes4J bugs that may obtain many extra failed tests which use relative paths to test projects, just like org.joda.time.TestSerialization#testSerializedMutableDateTime in Time_7.

As you mentioned, if GZoltar is initialized with the buggy program directory, there will be some unexpected exceptions.

So... I think GZoltar 0.1.1 may have several bugs in itself, which has already negatively affected the accuracy of current fault localization. It is really necessary and highly demanded to implement GZoltar with java. (This can be an idea as well as a meaningful contribution for the APR and FL community).

Finally, maybe this pull request still needs/deserves more explorations/efforts.

Thank you again for your reply.


if (classPaths != null && !classPaths.isEmpty()) {
gzoltar.getClasspaths().addAll(classPaths);
Expand Down Expand Up @@ -277,6 +283,10 @@ private void parseTestResults() {
// } else {
// totalFailedTestCases ++;
// }

// to print the failed tests
System.out.println("The failed test case:" + tr.getName() + " " + tr.wasSuccessful());

if (!failingTestCases.contains(testName)) failingTestCases.add(testName);
}
}
Expand Down