BRAFAR: Bidirectional Refactoring, Alignment, Fault Localization, and Repair for Programming Assignments
Brafar is a general feedback generation system for introductory programming assignments. Given a buggy program
- Java 11
- MacOS/Linux
- Build the project in the
brafar-system.jar. (We have already built Brafar tool in thebrafar-system.jar)
The Brafar tool takes a given buggy program, a set of correct programs and a set of testsuite as input.
The example/ directory contains a running example from the second assignment of the dataset:
|-example
| |-test
| | |-comp
| | | |-assignment2
| | | | |-SpecialNumberTest.java
| |
| |-correct
| | |-001
| | | |-src
| | | | |-comp
| | | | | |-assignment2
| | | | | | |-SpecialNumber.java
| | |-002
| | | |-src
| | | | |-comp
| | | | | |-assignment2
| | | | | | |-SpecialNumber.java
| | |-...
| | | |-src
| | | | |-comp
| | | | | |-assignment2
| | | | | | |-SpecialNumber.java
| |
| |-wrong
| | |-src
| | | |-comp
| | | | |-assignment2
| | | | | |-SpecialNumber.java
| |
| |-description.md
- The below command runs Brafar on the example code.
java -jar brafar-system.jar
--BuggyProgramSourceDir ./example/wrong/src
--CorrectProgramsSourceDir ./example/correct
--MethodToFix isSpecial@comp.assignment2.SpecialNumber
--ProgramTestClass comp.assignment2.SpecialNumberTest
--ProgramTestSourceDir ./example/test- Work Dir
brafar_system
--BuggyProgramSourceDir <BuggyProgramSourceDir>Path to the buggy program's source directory.--CorrectProgramsSourceDir <CorrectProgramSourceDir>Path to the correct programs' source directory.--MethodToFix <MethodToFix>Method to fix. Format: MethodName@Package Name.ClassName .--ProgramTestClass <ProgramTestClass>Class to the program test. Format: PackageName.ClassN ame .--ProgramTestSourceDir <ProgramTestSourceDir>Path to the program test source directory, separated by semicolon (;).--HelpPrint the help message.
S_Brafar will first format the buggy program and all the correct programs. Then S_Brafar will search the closest correct program for the buggy program as the repair reference. Then S_Brafar will use the searched reference program to repair the buggy program through four stages: Bidirectional Refactoring, Alignment, Fault Localization and Block Repair. The repair result is stored in output directory.
- The formatted codes are stored in
output/wrongandoutput/correct - The refactored codes are stored in
output/refactored - The repaired code is stored in
output/repaired
The "data" directory contains 400 correct and 601 incorrect programs from 6 different Java programming assignments offered during a second-year university course credited by students.
Brafar tool expects the following inputs:
- Test-suite: Junit test for this problem, that contains a set of test suite for this problem.
- Correct-P: Correct program attempts by students, that passes all the test-cases.
- Wrong-P: Buggy program attempts by students, which fails on one or more test-cases.
Given these inputs, Brafar tries to repair all buggy programs by inferring input-output specification from the closest aligned (refactored) correct programs. These data input files should be organized in the folder structure described below. Please refer to the 6 programming assignments present within "data" directory for example.
|-data
| |-Problemxx
| | |-test
| | | |-comp
| | | | |-assignmentX
| | | | | |-XXTest.java
| | |
| | |-correct
| | | |-001
| | | | |-src
| | | | | |-comp
| | | | | | |-assignmentX
| | | | | | | |-XX.java
| | | |-002
| | | | |-src
| | | | | |-comp
| | | | | | |-assignmentX
| | | | | | | |-XX.java
| | | |-...
| | | | |-src
| | | | | |-comp
| | | | | | |-assignmentX
| | | | | | | |-XX.java
| | |
| | |-wrong
| | | |-001
| | | | |-src
| | | | | |-comp
| | | | | | |-assignmentX
| | | | | | | |-XX.java
| | | |-002
| | | | |-src
| | | | | |-comp
| | | | | | |-assignmentX
| | | | | | | |-XX.java
| | | |-...
| | | | |-src
| | | | | |-comp
| | | | | | |-assignmentX
| | | | | | | |-XX.java
| | |-desscription.md