SpoonLabs / astor

Automatic program repair for Java with generate-and-validate techniques :v::v:: jGenProg (2014) - jMutRepair (2016) - jKali (2016) - DeepRepair (2017) - Cardumen (2018) - 3sfix (2018)
https://hal.archives-ouvertes.fr/hal-01321615/document
GNU General Public License v2.0
208 stars 106 forks source link

feature: add filepath in PatchDiff #90

Closed surli closed 6 years ago

surli commented 6 years ago

When a ProgramVariant is a solution, I currently get the PatchDiff to get its formatted diff. Is it possible to also record the path of the file to patch somewhere?

martinezmatias commented 6 years ago

Hi @surli , Yes, It's done. You can find both patches diffs (formatted and not formatted) inside the output folder: e.g. (not formatted)

/astor/output_astor/AstorMain-math_70/src/variant-44/patch.diff and (formatted) /astor/output_astor/AstorMain-math_70/src/variant-44_f/patch.diff
surli commented 6 years ago

I think you misunderstood my request. I want to be able to get the path of the file(s) that will be changed by the produced patch. For example the patch would be applied on src/main/java/MySuperClass.java, I want to get that path.

martinezmatias commented 6 years ago

Hi @surli Sorry for my misunderstand. I get your point. Currently that information is not provided. I will implement it right now. Regards Matias

martinezmatias commented 6 years ago

Hi @surli I commit the feature: now, you can find the patch to the modified files in the standard output and JSON files. E.g., PATH=/astor/examples/math_70/src/main/java/org/apache/commons/math/analysis/solvers/BisectionSolver.java

LINE=72

SUSPICIOUNESS=1

....

ORIGINAL_CODE=return solve(min, max) ....

surli commented 6 years ago

you can find the patch to the modified files in the standard output and JSON files.

Isn't it available through the java API? I wanted to access it while I get the diff and right now I'm doing this:

for (ProgramVariant pv : solutions) {
   if (pv.isSolution()) {
      String diff = pv.getPatchDiff().getFormattedDiff();
   }
}
martinezmatias commented 6 years ago

I added a way, see this test: https://github.com/SpoonLabs/astor/blob/master/src/test/java/fr/inria/astor/test/repair/core/OutputTest.java#L197

surli commented 6 years ago

Great thanks!