-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
417 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
generator/src/main/java/fr/inria/diversify/runner/SmartRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package fr.inria.diversify.runner; | ||
|
||
import fr.inria.diversify.statistic.SinglePointSessionResults; | ||
import fr.inria.diversify.transformation.AddMethodInvocation; | ||
import fr.inria.diversify.transformation.SingleTransformation; | ||
import fr.inria.diversify.transformation.Transformation; | ||
import fr.inria.diversify.util.Log; | ||
import spoon.reflect.declaration.CtMethod; | ||
import spoon.reflect.declaration.CtParameter; | ||
|
||
import java.util.List; | ||
import java.util.Properties; | ||
|
||
public class SmartRunner extends SinglePointRunner { | ||
public SmartRunner(InputConfiguration inputConfiguration, String projectDir, String srcDir) { | ||
super(inputConfiguration, projectDir, srcDir); | ||
|
||
} | ||
|
||
private void initTraces() { | ||
String tracesDir = inputConfiguration.getProperty("traces"); | ||
if(tracesDir != null) { | ||
|
||
} | ||
} | ||
|
||
private String buildAgentLine(String test) { | ||
if(inputConfiguration.getProperty("traces") == null) return null; | ||
if(inputConfiguration.getProperty("traceAgent") == null) return null; | ||
if(inputConfiguration.getProperty("tracePackage") == null) return null; | ||
return"-javaagent:" + | ||
inputConfiguration.getProperty("traceAgent") + | ||
"=\"strict-includes|includes=" + | ||
inputConfiguration.getProperty("tracePackage") + | ||
"|excludes=fr.inria.yalta|follow=" + | ||
inputConfiguration.getProperty("traces") + | ||
"/" + test + | ||
"\""; | ||
} | ||
|
||
@Override | ||
protected void run(Transformation trans) throws Exception { | ||
Log.info("trial {}", trial); | ||
Log.debug("output dir: " + tmpDir + "/" + sourceDir); | ||
// writePosition(tmpDir + "/transplant.json", (ASTTransformation) trans); | ||
|
||
try { | ||
applyTransformation(trans); | ||
|
||
try { | ||
int status; | ||
if(trans instanceof SingleTransformation) { | ||
SingleTransformation a = (SingleTransformation) trans; | ||
Properties p = new Properties(); | ||
if(testImpact != null) { | ||
p.setProperty("test", getTests(a.methodLocationName())); | ||
p.setProperty("argLine", buildAgentLine(getTests(a.methodLocationName()))); | ||
} | ||
status = runTest(tmpDir, p); | ||
} else { | ||
status = runTest(tmpDir); | ||
} | ||
|
||
|
||
// if(status == 0) { | ||
// writeAllInfo((SingleTransformation) trans, trial); | ||
// } | ||
|
||
trans.setStatus(status); | ||
trans.setFailures(builder.getFailedTests()); | ||
// error during runTest | ||
} catch (Exception e) { | ||
trans.setStatus(-2); | ||
Log.debug("compile error during diversification", e); | ||
} | ||
|
||
trial++; | ||
trans.restore(tmpDir + "/" + sourceDir); | ||
|
||
((SinglePointSessionResults) sessionResults).addRunResults(trans); | ||
} catch (Exception e) { | ||
trans.setStatus(-2); | ||
tryRestore(trans, e); | ||
} | ||
transformations.add(trans); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
generator/src/main/java/fr/inria/diversify/transformation/ForEachFlip.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package fr.inria.diversify.transformation; | ||
|
||
import fr.inria.diversify.transformation.exception.RestoreTransformationException; | ||
import spoon.reflect.code.CtExpression; | ||
import spoon.reflect.code.CtForEach; | ||
import spoon.reflect.cu.SourcePosition; | ||
import spoon.reflect.declaration.CtClass; | ||
import spoon.reflect.declaration.CtPackage; | ||
import spoon.reflect.declaration.CtType; | ||
import spoon.reflect.factory.Factory; | ||
|
||
public class ForEachFlip extends SingleTransformation { | ||
CtClass host; | ||
CtForEach tp; | ||
Factory f; | ||
CtType newType; | ||
public ForEachFlip(CtForEach tp) { | ||
host = tp.getParent(CtClass.class); | ||
this.tp = tp; | ||
f = tp.getFactory(); | ||
//newType = f.Class().create() | ||
} | ||
|
||
@Override | ||
public String classLocationName() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String packageLocationName() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String methodLocationName() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public SourcePosition getPosition() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public int line() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public String getTransformationString() throws Exception { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void apply(String srcDir) throws Exception { | ||
//ctPackage.addType() | ||
CtExpression old = tp.getExpression(); | ||
CtExpression newE = f.Code().createCodeSnippetExpression(""); | ||
//tp.setExpression() | ||
} | ||
|
||
@Override | ||
public void restore(String srcDir) throws RestoreTransformationException { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.