-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun-coverage.sh
executable file
·109 lines (91 loc) · 3.29 KB
/
run-coverage.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
OUTPUT_DIR=$1
PROJECT=$2
DIR_SF_110=$3
if [[ -z "$OUTPUT_DIR" || -z "$PROJECT" || -z "$DIR_SF_110" ]];
then
echo "missing variable. please check and set before calling!"
echo OUTPUT_DIR=$OUTPUT_DIR
echo PROJECT=$PROJECT
echo DIR_SF_110=$DIR_SF_110
exit
fi
#########
## Compiling, generating list and reading the tests
#########
## building claspath
PROJECT_JAR=$(echo "$PROJECT" | cut -f2 -d\_)".jar"
PROJECT_CLASSPATH="$DIR_SF_110/${PROJECT}/$PROJECT_JAR"
for x in `find $DIR_SF_110/${PROJECT}/lib -name "*.jar"`;
do
PROJECT_CLASSPATH=$x:${PROJECT_CLASSPATH}
done
## this directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
RANDOOP_JAR=${DIR}/libs/randoop/randoop-all-4.1.1.jar
EVOSUITE_JAR=${DIR}/libs/evosuite/evosuite-1.0.6.jar
## defining some important paths
JACOCO_DIR=${DIR}/libs/jacoco
JACOCO_AGENT=${JACOCO_DIR}/jacocoagent.jar
JACOCO_CLI=${JACOCO_DIR}/jacococli.jar
JUNIT_JARS=${DIR}/libs/junit/hamcrest-core-1.3.jar:${DIR}/libs/junit/junit-4.13-beta-2.jar
cd ${OUTPUT_DIR};
## compile all tests
CP=${PROJECT_CLASSPATH}:${JUNIT_JARS}:${EVOSUITE_JAR}
find . -name "*.java" | xargs javac -cp $CP -d .
## executing tests as to generate jacoco.exec files
tmp=$(basename $OUTPUT_DIR)
if [[ $tmp == randoop+evosuite* ]]
then
echo "Running Randoop + EvoSuite tests..."
###################################
## running Randoop + EvoSuite tests
###################################
## running Randoop tests
java -cp .:$CP -javaagent:${JACOCO_AGENT} org.junit.runner.JUnitCore synapse.RegressionTest
mv jacoco.exec jacoco.exec.$file
## running Evosuite tests
EVOTESTS="${DIR}/list-of-classes-EVO.txt"
find . -name "*.class" | sed 's/\.class//g' | sed 's/\.\///g' | sed 's/\//./g' > ${EVOTESTS}
## process file
while IFS= read -r file
do
echo "Reading... $file"
java -cp .:$CP -javaagent:${JACOCO_AGENT} org.junit.runner.JUnitCore $file
mv jacoco.exec jacoco.exec.$file
done < "$EVOTESTS"
rm $EVOTESTS
## merge jacoco.exec files into one and delete the rest
covfiles=$(find . -name "jacoco.exec*" | xargs)
java -jar $JACOCO_CLI merge $covfiles --destfile jacoco.exec
rm $covfiles
elif [[ $tmp == randoop* ]];
then
echo "Running Randoop tests..."
#########################
## running Randoop tests
#########################
java -cp .:$CP -javaagent:${JACOCO_AGENT} org.junit.runner.JUnitCore synapse.RegressionTest
else
echo "Running EvoSuite tests..."
#########################
## running EvoSuite tests
#########################
EVOTESTS="${DIR}/list-of-classes-EVO.txt"
find . -name "*.class" | sed 's/\.class//g' | sed 's/\.\///g' | sed 's/\//./g' > ${EVOTESTS}
## process file
while IFS= read -r file
do
echo "Reading... $file"
java -cp .:$CP -javaagent:${JACOCO_AGENT} org.junit.runner.JUnitCore $file
mv jacoco.exec jacoco.exec.$file
done < "$EVOTESTS"
rm $EVOTESTS
## merge jacoco.exec files into one and delete the rest
covfiles=$(find . -name "jacoco.exec*" | xargs)
java -jar $JACOCO_CLI merge $covfiles --destfile jacoco.exec
rm $covfiles
fi
java -jar $JACOCO_CLI report jacoco.exec \
--classfiles ${PROJECT_CLASSPATH} \
--csv jacoco.csv
rm jacoco.exec