Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
simonAllier committed Mar 19, 2014
1 parent 243afd0 commit f6b8e5a
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 22 deletions.
11 changes: 5 additions & 6 deletions src/main/java/fr/inria/diversify/DiversifyMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ public DiversifyMain(String propertiesFile) throws Exception {
}
initSpoon();

// Log.info("number of statement: " + codeFragments.size());
// Log.info("candidate: {}", test());
if (DiversifyProperties.getProperty("stat").equals("true")) {
computeStatistic();

Expand All @@ -77,9 +75,10 @@ protected void initAndRunBuilder() throws Exception {
abstractDiversify.run(n);

String repo = DiversifyProperties.getProperty("gitRepository");
if(repo.equals(""))
repo = "tmp";
abstractDiversify.printResult(DiversifyProperties.getProperty("result"),repo+"/diversify-exp");
if(repo.equals("null"))
abstractDiversify.printResult(DiversifyProperties.getProperty("result"));
else
abstractDiversify.printResult(DiversifyProperties.getProperty("result"),repo+"/diversify-exp");
}

protected AbstractDiversify initAbstractDiversify() throws Exception {
Expand All @@ -95,7 +94,7 @@ else if(DiversifyProperties.getProperty("sosie").equals("classic"))
else
ad = new MutantSosieWriter(projet,src);

String tmpDir = ad.init(projet, DiversifyProperties.getProperty("outputDir"));
String tmpDir = ad.init(projet, DiversifyProperties.getProperty("tmpDir"));
ad.setBuilder(initBuilder(tmpDir));

return ad;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ public JSONObject toJSONObject() throws JSONException {
JSONObject object = new JSONObject();
object.put("position", positionString());
object.put("type", getCodeFragmentType().getSimpleName());
object.put("inputContext", new JSONArray(getInputContext().inputContextToString()));
object.put("outputContext", getOutputContext().toString());
// object.put("inputContext", new JSONArray(getInputContext().inputContextToString()));
// object.put("outputContext", getOutputContext().toString());
object.put("sourceCode", equalString());
return object;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,28 @@ public abstract class AbstractDiversify {

public abstract void run(Collection<Transformation> trans) throws Exception;

public void printResult(String output, String git) {
mkDirResult(output,git);
public String printResult(String output) {
mkDirResult(output);
String fileName = output + System.currentTimeMillis() + "_transformation.json";
String absoluteFileName = git + "/" + fileName;
String absoluteFileName = output + "/" + fileName;
try {
writeTransformation(absoluteFileName);
Log.info("write result in {}", absoluteFileName);
} catch (Exception e) {
Log.error("error in Builder.printResult", e);
}
if(!git.equals("")) {
return absoluteFileName;
}

public void printResult(String output, String git) {
String absoluteFileName = printResult(git+"/"+output);

String[] split = absoluteFileName.split("/");
String tmp = split[0];
for (int i = 1;i < split.length - 1; i++) {
tmp = tmp + "/" + split[i];
}

Log.debug(tmp+"/ "+split[split.length - 1]);
GitUtil.addToGit(tmp+"/", "*");
}
}

public void writeTransformation(String fileName) throws IOException, JSONException {
Expand All @@ -61,9 +62,9 @@ public void writeTransformation(String fileName) throws IOException, JSONExcepti
write.writeAllTransformation(null);
}

protected void mkDirResult(String output, String git) {
protected void mkDirResult(String output) {
String[] tmp = output.split("/");
String dirs = git +"/";
String dirs = "";
for (int i = 0; i< tmp.length - 1;i++) {
dirs = dirs + tmp[i] + "/";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public JSONObject toJSONObject() throws JSONException {

CodeFragmentEqualPrinter pp = new CodeFragmentEqualPrinter(object.getFactory().getEnvironment());
object.accept(pp);
json.put("object", pp.toString());
// json.put("object", pp.toString());
json.put("nodeType", stmtType());

return json;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public JSONObject toJSONObject() throws JSONException {

CodeFragmentEqualPrinter pp = new CodeFragmentEqualPrinter(transplant.getFactory().getEnvironment());
transplant.accept(pp);
json.put("transplant", pp.toString());
// json.put("transplant", pp.toString());

if(classOrInterfaceSubstitution != null)
json.put("classOrInterfaceExistence",classOrInterfaceSubstitution.getPackage()+"."+classOrInterfaceSubstitution.getSimpleName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public JSONObject toJSONObject() throws JSONException {

CodeFragmentEqualPrinter pp = new CodeFragmentEqualPrinter(transplant.getFactory().getEnvironment());
transplant.accept(pp);
json.put("transplant", pp.toString());
// json.put("transplant", pp.toString());

return json;
}
Expand Down
17 changes: 15 additions & 2 deletions src/main/java/fr/inria/diversify/util/DiversifyProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,24 @@ protected void setDefaultProperties() {
prop.setProperty("transformation.size","1");
prop.setProperty("stat", "false");
prop.setProperty("sosie", "false");
prop.setProperty("outputDir", "output_diversify");

//tempory directory
prop.setProperty("tmpDir", "tmpDir");

//directory for ouput (ex sosie)
prop.setProperty("outputDirectory", "output");

//directory for ouput (ex sosie)
prop.setProperty("result", "output_diversify");

//file name with path for result (ex json file, stat file)
//if gitRepository != null all result are put in gitRepository/result
prop.setProperty("result", "output_diversify");

prop.setProperty("sosieOnMultiProject","false");
prop.setProperty("timeOut","-1");
prop.setProperty("logLevel", "2");
prop.setProperty("gitRepository", "");
prop.setProperty("gitRepository", "null");
prop.setProperty("processor", "fr.inria.diversify.codeFragmentProcessor.StatementProcessor");
prop.setProperty("syncroRange","0");
prop.setProperty("newPomFile","");
Expand Down
11 changes: 11 additions & 0 deletions utils/easymock/gridAll.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
project=../easymock
src=easymock/src/main/java
classes=easymock/target/classes
nbRun=100
timeOut=-1
result=all/easymock/trans
gitRepository=repo
transformation.size=1
transformation.type=all
jacoco=utils/easymock/jacoco.exec
javaVersion=5

0 comments on commit f6b8e5a

Please sign in to comment.