1. 下载
2. 安装
2.1 环境需求
- Java 1.8
- Git >= 1.9
- SVN >= 1.8
- Perl >= 5.0.12
Java 和 Git 不赘述(注意 JDK 版本)。
sudo apt-get install subversion
sudo apt-get install cpanminus
其中,Perl 模块需要(由 D4J 初始化程序负责安装):
- DBI >= 1.63
- DBD::CSV >= 0.48
- URI >= 1.72
- JSON >= 2.97
- JSON::Parse >= 0.55
- List::Util >= 1.33
2.2 安装步骤
# 1.Clone Defects4J:
git clone https://github.com/rjust/defects4j
# 2.Initialize Defects4J
cd defects4j
cpanm --installdeps .
./init.sh
# 3.Add Defects4J's executables to PATH:
export PATH=$PATH:"path2defects4j"/framework/bin
# 4.Check installation:
defects4j info -p Lang
第二步过程可能会出现依赖安装失败的情况:
Installing the dependencies failed: Module 'DBI' is not installed, Module 'DBD::CSV' is not installed, Module 'JSON::Parse' is not installed
解决方案:到 CPAN 下载对应模块,解压并安装(需要编译环境)。本人安装的过程中,DBD::CSV 测试过程有两个 subtest 失败,目前未发现影响。
sudo apt install build-essential
perl Makefile.PL
make
make test
sudo make install
3. 使用
执行 Checkout 指令:
defects4j checkout -p Lang -v 1b -w "d4j-workDirectory"/lang_1_buggy
Checking out 687b2e62 to /root/lang_1_buggy................................ OK
Init local repository...................................................... OK
Tag post-fix revision...................................................... OK
Excluding broken/flaky tests............................................... OK
Excluding broken/flaky tests............................................... OK
Excluding broken/flaky tests............................................... OK
Initialize fixed program version........................................... OK
Apply patch................................................................ OK
Initialize buggy program version........................................... OK
Diff 687b2e62:2c454a4c..................................................... OK
Apply patch................................................................ OK
Tag pre-fix revision....................................................... OK
Check out program version: Lang-1b......................................... OK
结果如图所示: