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

initial commit for iFixFlakies4iFixPlus #24

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

ChopinLi-cp
Copy link

No description provided.

import org.xmlunit.diff.Difference;
import org.xmlunit.diff.ElementSelectors;

public class iFixPlusPlugin extends TestPlugin {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we should change this to something like ODRepairPlugin, or ODRepairDebugPlugin, as to better match the paper.


public class iFixPlusPlugin extends TestPlugin {
private Path replayPath;
private Path replayPath2;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use a better name than replayPath2 as to distinguish what it is actually supposed to represent?

final Runner runner = InstrumentingSmartRunner.fromRunner(runners.get(0));

replayPath = Paths.get(Configuration.config().getProperty("replay.path"));
replayPath2 = Paths.get(Configuration.config().getProperty("replay.path2"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similar thing about the property name itself. In fact, should they all have the prefix "replay"? If they are more relevant for controlling testrunner's statecapture logic, maybe they should instead be prefix "statecapture"?

// phase 0 check json file
System.out.println("~~~~~~ Begin to check if this test is a true order-dependent test.");
Configuration.config().properties().setProperty("statecapture.phase", "check");
if (testFailOrder()==null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Spaces between operators, i.e., testFailOrder() == null.

StandardOpenOption.APPEND);
// phase 0 check json file
System.out.println("~~~~~~ Begin to check if this test is a true order-dependent test.");
Configuration.config().properties().setProperty("statecapture.phase", "check");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does configuring the phase to be "check" affect anything for the testrunner run itself?

System.out.println("xmlFileName: " + xmlFileNum);

if (runner != null && module.equals(PathManager.modulePath().toString())) {
System.out.println("replyPath: " + replayPath);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can remove such print statements; also, replyPath -> replayPath.


@Override
public void execute(final MavenProject mavenProject) {
Configuration.config().properties().setProperty("statecapture.phase", "initial");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does setting the phase to be "initial" affect anything?

}

for(int i=0; i<10; i++) {
Try<TestRunResult> phase0ResultFail = null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's also change the variable names to not use numbered phases, to match exactly what phase we care about.

phase0ResultFail = runner.runList(testFailOrder());
}
catch (Exception ex) {
System.out.println("## Encountering error when checking the failing order: " + ex);
Copy link
Collaborator

Choose a reason for hiding this comment

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

What kind of exceptions can we get there?

System.out.println("Failing order results: " +
phase0ResultFail.get().results().get(dtname).result().toString());

if (phase0ResultFail.get().results().get(dtname).result().toString().equals("PASS")) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since the variable gets initalized to null and can potentially not be set properly in the try block, this could actually lead to a NullPointerException. That kind of defeats the purpose of using the Try construct, since the point of that is to not have to check for null (you would first check whether it has a value).

System.out.println("## Running double victim order results: " + phase1Result.get().results());
}
catch (Exception e) {
System.out.println("## Encountering error when running in double victim order: " + e);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please check what kind of exceptions we can get in these places.


replayPath = Paths.get(Configuration.config().getProperty("replay.path"));
replayPath2 = Paths.get(Configuration.config().getProperty("replay.path2"));
dtname= Configuration.config().getProperty("replay.dtname");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Spaces after the variable name.

System.out.println("~~~~~~ Finish phase capturing the state in passing order(double victim)!!");
}

xmlFileNum = countDirNums(subxmlFold);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we still need to do these counting?

Configuration.config().properties().
setProperty("statecapture.phase", "capture_before");
Configuration.config().properties().
setProperty("statecapture.state", "passing_order");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this "statecapture.state" property actually useful?

System.out.println("~~~~~~ Begin capturing the state in passing order!");
// phase 2: run doublevictim order state capture
Configuration.config().properties().
setProperty("statecapture.phase", "capture_after");
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder instead of "phase" the property should actually reflect that it means the relative position for capture, maybe something like "statecapture.position"?

xmlFileNum = countDirNums(subxmlFold);
System.out.println("xmlFileNum: " + xmlFileNum);

File passingSubXmlFolder = new File(subxmlFold + "/failing_order_xml");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is passingSubXmlFolder referencing the name "failing_order_xml"?

String line;
while ((line = br.readLine()) != null) {
if (line.contains(" made test success#######")) {
successfulField = line.substring(8, line.lastIndexOf(" made test success#######"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

This feels so complicated to parse some English, can we get it to simply write out the valid polluted field?

return num;
}

public void diffing() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If all diffing does is call diffSub, is there any need for this method?

return FileUtils.readFileToString(file, "UTF-8");
}

Set<String> File2SetString(String path) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Method should not start with capitalized letter, should have access modifier like private, maybe change to something like readFileContentsAsSet.

}

if (!state0.equals(state1)) {
diffFields_filtered.add(s);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this just compare whether the two strings read from the files are exactly the same? Shouldn't there be a more in-depth comparison to determine whether they are truly different?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants