forked from WCSim/Validation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTests.sh
executable file
·276 lines (185 loc) · 6.7 KB
/
Tests.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
#!/bin/bash
cd $ValidationPath/Compare
g++ compareroot.cpp -o compareroot `root-config --libs --cflags`
cd ../
if [ ! -d "${ValidationPath}/Webpage" ]; then
git clone https://github.com/WCSim/Validation.git -b gh-pages ./Webpage
fi
cd /opt/WCSim
if [[ -z ${TRAVIS_PULL_REQUEST} ]]; then
TRAVIS_PULL_REQUEST=false
fi
echo showing travis commit
echo ${TRAVIS_COMMIT}
echo showing travis pull request
echo ${TRAVIS_PULL_REQUEST}
ret=0
##################### Setting up new table entry #############################
if [ $1 -eq 1 ]
then
if [ $TRAVIS_PULL_REQUEST != "false" ]
then
TRAVIS_COMMIT_MESSAGE=" Pull Request #${TRAVIS_PULL_REQUEST}"
fi
cp $ValidationPath/Webpage/results.html $ValidationPath/Webpage/results.html.old
echo "
<tr>
<th scope='col'><div align='center'>Commit ID</div></th>
<th scope='col'><div align='center'>Description</div></th>
" >$ValidationPath/Webpage/results.html.new;
while read line
do
if [ ${line::1} != "#" ]
then
name=$(echo $line | cut -f1 -d' ')
echo " <th scope='col'><div align='center'>"$name"</div></th>" >> $ValidationPath/Webpage/results.html.new;
fi
done < $ValidationPath/tests.txt
echo " </tr>
<tr>
<td>"${TRAVIS_COMMIT}"</td>
<td>"${TRAVIS_COMMIT_MESSAGE}"</td>">> $ValidationPath/Webpage/results.html.new;
i=0
while read line
do
if [ ${line::1} != "#" ]
then
i=$(expr 1 + $i)
name=$(echo $line | cut -f1 -d' ')
echo " <td bgcolor=\""${TRAVIS_COMMIT}"Pass"$i"\"><a href='"${TRAVIS_COMMIT}"Link"$i"'>"${TRAVIS_COMMIT}"Text"$i$"</td>" >> $ValidationPath/Webpage/results.html.new;
fi
done < $ValidationPath/tests.txt
echo " </tr>
" >> $ValidationPath/Webpage/results.html.new
head -300 $ValidationPath/Webpage/results.html.old >>$ValidationPath/Webpage/results.html.new
cp $ValidationPath/Webpage/results.html.new $ValidationPath/Webpage/results.html
mkdir $ValidationPath/Webpage/${TRAVIS_COMMIT}
i=0
while read line
do
if [ ${line::1} != "#" ]
then
i=$(expr 1 + $i)
mkdir $ValidationPath/Webpage/${TRAVIS_COMMIT}/$i
echo placeholder > $ValidationPath/Webpage/${TRAVIS_COMMIT}/$i/placeholder
fi
done < $ValidationPath/tests.txt
echo ${TRAVIS_COMMIT} >$ValidationPath/Webpage/folderlist.new
head -35 $ValidationPath/Webpage/folderlist >> $ValidationPath/Webpage/folderlist.new
mv $ValidationPath/Webpage/folderlist.new $ValidationPath/Webpage/folderlist
##### clean up ####
folder=0
while read line
do
folder=$(expr 1 + $folder)
if [ $folder -ge 30 ]
then
rm -rf $line
fi
done < $ValidationPath/Webpage/folderlist
##################
fi
#########################################################################################
################################### Running tests ######################################
i=0
while read line
do
if [ ${line::1} != "#" ]
then
name=$(echo $line | cut -f1 -d' ')
test=$(echo $line | cut -f2 -d' ')
var1=$(echo $line | cut -f3 -d' ')
var2=$(echo $line | cut -f4 -d' ')
var3=$(echo $line | cut -f5 -d' ')
var4=$(echo $line | cut -f6 -d' ')
i=$(expr $i + 1)
if [ $i -eq $1 ]
then
################## Build Test #######################
if [ $test == "BuildTest" ]
then
/usr/bin/time -p --output=timetest $var1 |& tee $ValidationPath/Webpage/${TRAVIS_COMMIT}/"log"$1
ret=${?}
time=`more timetest |grep user | cut -f2 -d' '`
if [ ! -e $var2 ]
then
pass=#FF0000
ret=1
else
pass=#00FF00
ret=0
fi
cp $ValidationPath/Webpage/results.html $ValidationPath/Webpage/results.html.old
head -1000000 $ValidationPath/Webpage/results.html.old | sed s:${TRAVIS_COMMIT}"Pass"$1:$pass: | sed s:${TRAVIS_COMMIT}"Text"$i:$time: | sed s:${TRAVIS_COMMIT}"Link"$1:${TRAVIS_COMMIT}/log$1: > $ValidationPath/Webpage/results.html.new
fi
#############################################################
################## File Test #######################
if [ $test == "FileTest" ]
then
if [ ! -e $var1 ]
then
pass=#FF0000
text="Not present"
ret=0
else
pass=#00FF00
text="Present"
ret=1
fi
file="index.html"
cp $ValidationPath/Webpage/results.html $ValidationPath/Webpage/results.html.old
head -1000000 $ValidationPath/Webpage/results.html.old | sed s:${TRAVIS_COMMIT}"Pass"$1:$pass: | sed s:${TRAVIS_COMMIT}"Text"$i:$text: | sed s:${TRAVIS_COMMIT}"Link"$1:$file: > $ValidationPath/Webpage/results.html.new
fi
#############################################################
################## Physics Validation #######################
if [ $test == "PhysicsValidation" ]
then
/usr/bin/time -p --output=timetest $var1 $var2
if [ $? -ne 0 ]
then
pass=#FF0000
time="Failed"
ret=1
else
time=`more timetest |grep user | cut -f2 -d' '`
$ValidationPath/Compare/compareroot $ValidationPath/Webpage/${TRAVIS_COMMIT}/$1 "analysed_"$name".root" $var3
if [ $? -ne 0 ]
then
pass=#FF0000
time="Failed"
ret=1
else
pass=#00FF00
ret=0
fi
fi
cd $ValidationPath/Webpage
git pull
cd -
cp $ValidationPath/Webpage/results.html $ValidationPath/Webpage/results.html.old
head -1000000 $ValidationPath/Webpage/results.html.old | sed s:${TRAVIS_COMMIT}"Pass"$1:$pass: | sed s:${TRAVIS_COMMIT}"Text"$i:$time: | sed s:${TRAVIS_COMMIT}"Link"$1:${TRAVIS_COMMIT}/$1/index.html: > $ValidationPath/Webpage/results.html.new
fi
#############################################################
fi
fi
done < $ValidationPath/tests.txt
#############################################################
############################## update webpage ################
cd $ValidationPath/Webpage
git pull
head -100000000 header.html > index.html
mv results.html.new results.html
head -100000000 results.html >> index.html
head -100000000 footer.html >>index.html
rm results.html.old
#add a default user, otherwise git complains
git config user.name "Travis CI"
git config user.email "[email protected]"
git add --all
git commit -a -m'Travis update'
#git push
#> /dev/null 2>/dev/null
git push https://tdealtry:${GitHubToken}@github.com/tdealtry/Validation.git gh-pages
#> /dev/null 2>/dev/null
#git push "https://${TRAVIS_SECURE_TOKEN_NAME}@${GH_REPO}" gh-pages > /dev/null 2>&1
exit $ret