forked from rjust/defects4j
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_tutorial.sh
executable file
·59 lines (48 loc) · 1.97 KB
/
test_tutorial.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
################################################################################
#
# This script tests the tutorial as described in Defects4J's README file.
#
################################################################################
# Import helper subroutines and variables, and init Defects4J
source test.include
init
# Get project info
defects4j info -p Lang || die "print project info"
# Get bug info
defects4j info -p Lang -b 1 || die "print bug info"
pid=Lang
bid=1
vid=${bid}b
work_dir=$TMP_DIR/$pid-$vid
# Checkout buggy version
defects4j checkout -p $pid -v $vid -w $work_dir || die "checkout program version $pid-$vid"
# Verify that defects4j's config file exists
[ -e $work_dir/.defects4j.config ] || die "read config file"
# Verify that defects4j's config file provides the correct data
grep -q "pid=$pid" $work_dir/.defects4j.config || die "verify pid in config file"
grep -q "vid=$vid" $work_dir/.defects4j.config || die "verify vid in config file"
cd $work_dir
# Compile buggy version
defects4j compile || die "compile program version $pid-$vid"
# Run tests for buggy version and verify triggering tests
defects4j test -r || die "test program version $pid-$vid"
actual_file="$work_dir/failing_tests"
expected_file="$BASE_DIR/framework/projects/$pid/trigger_tests/$bid"
actual=$(num_triggers "$actual_file")
expected=$(num_triggers "$expected_file")
if [ "$actual" -ne "$expected" ] ; then
echo "Actual triggers from $actual_file :"
get_triggers "$actual_file"
echo "Expected triggers from $expected_file :"
get_triggers "$expected_file"
die "verify number of triggering tests"
fi
vid=${bid}f
# Checkout fixed version
defects4j checkout -p $pid -v $vid -w . || die "checkout program version $pid-$vid"
# Compile fixed version
defects4j compile || die "compile program version $pid-$vid"
# Run coverage and mutation analysis
defects4j coverage -r || die "coverage analysis $pid-$vid"
defects4j mutation -r || die "coverage analysis $pid-$vid"