forked from STAMP-project/pitmp-maven-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
verify_pitmp.sh
executable file
·136 lines (123 loc) · 4.11 KB
/
verify_pitmp.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/sh
################################################################################
printUsage()
{
echo "Usage: $ScriptName [-h | -clean | [-v <version> | -pv <pitest_version>]]"
}
################################################################################
help()
{
printUsage
echo
echo "Compile, install locally and run automatic tests to verify PitMP plugin."
echo "Tests are located in the directory:"
echo " $testDirName"
echo " ├── dhell"
echo " └── dnoo"
echo "Options:"
echo "-h: this help."
echo "-clean: clean all files generated by a previous executions."
echo "-v <version>: version of PitMP to be tested."
echo " Default value: the version in the file pom.xml."
echo "-pv <pitest_version>: version of PITest to be tested."
echo " Default value: the version in the file pom.xml."
exit 0
}
################################################################################
usage()
{
printUsage
exit 1
}
################################################################################
# commandline analysis
ScriptName=`basename "$0"`
currentDir=`pwd`
dirList="dhell dnoo"
testName="verify_pitmp"
traceFile="$currentDir/$testName.traces"
compileFile=$currentDir/$testName"_compile.traces"
testDirName="test_dir"
testDir="$currentDir/$testDirName"
runResFile="$testDir/run_all_tests.res"
refResult="$testDir/$testName.ref"
tmpResFile=$testDir/$testName"_res.$$"
tmpDiffFile=$testDir/$testName"_diff.$$"
pomFile="pom.xml"
execOption="run"
scriptOptions=
while test ! "X$1" = "X"
do
if test "$1" = "-h"
then
help
elif test "$1" = "-clean"
then
execOption="clean"
elif test "$1" = "-runfrompom"
then
execOption="runfrompom"
else
scriptOptions="$scriptOptions $1"
fi
shift
done
################################################################################
# clean previous trace files
rm -f $traceFile $compileFile $runResFile $testDir/$testName"_diff".* $testDir/$testName"_res".*
if test "$execOption" = "run" || test "$execOption" = "runfrompom"
then
mvnInstallOk="false"
if test "$execOption" = "run"
then
echo "------------------------------------------------------------" 2>&1 | tee -a $traceFile
echo "- compile and install locally" 2>&1 | tee -a $traceFile
echo "------------------------------------------------------------" 2>&1 | tee -a $traceFile
if mvn clean install >> $compileFile 2>&1
then
echo "OK" 2>&1 | tee -a $traceFile
mvnInstallOk="true"
else
echo "FAILED" 2>&1 | tee -a $traceFile
echo "-------- traces" 2>&1 | tee -a $traceFile
cat "$compileFile" 2>&1 | tee -a $traceFile
fi
elif test -d "target"
then
mvnInstallOk="true"
fi
if "$mvnInstallOk" = "true"
then
echo "------------------------------------------------------------" 2>&1 | tee -a $traceFile
echo "- running tests" 2>&1 | tee -a $traceFile
echo "------------------------------------------------------------" 2>&1 | tee -a $traceFile
cd $testDir
./run_all_tests.sh $scriptOptions >$runResFile 2>&1
# check result
grep "^########" $runResFile > $tmpResFile
if diff $tmpResFile $refResult >$tmpDiffFile
then
echo "OK" 2>&1 | tee -a $traceFile
# clean all traces files
rm -f $traceFile $compileFile $runResFile $testDir/$testName"_diff".* $testDir/$testName"_res".*
exit 0
else
echo "FAILED" 2>&1 | tee -a $traceFile
echo "-------- results" 2>&1 | tee -a $traceFile
cat "$tmpResFile" 2>&1 | tee -a $traceFile
echo "-------- diff" 2>&1 | tee -a $traceFile
cat "$tmpDiffFile" 2>&1 | tee -a $traceFile
# remove trace files except the main one
rm -f $compileFile $runResFile $testDir/$testName"_diff".* $testDir/$testName"_res".*
exit 1
fi
else
# remove trace files except the main one
rm -f $compileFile $runResFile $testDir/$testName"_diff".* $testDir/$testName"_res".*
exit 1
fi
else
cd $testDir
./run_all_tests.sh -clean $scriptOptions
fi
exit 0