-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathruntests
executable file
·367 lines (305 loc) · 9.29 KB
/
runtests
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
#!/bin/bash
##
## $Revision$ $Date$
##
# TomEE 7.x is compiled with Java 7
#if [ -d $HOME/jdk7 ]; then
# export JAVA_HOME=$HOME/jdk7
#fi
PROGNAME=`basename $0`
DIRNAME=`dirname $0`
DEFAULT_WEB="none"
DEFAULT_SQL="active"
warn() {
echo "${PROGNAME}: $*"
}
die() {
warn "$*"
exit 1
}
usage() {
cat <<EOF
usage: $PROGNAME [options] <test> [<test> ...] [mvn options]
options:
-h,--help Display help information
-w,--web <container> Specify the container to test with (default: $DEFAULT_WEB)
-sql <skip|active> Wether sql databases should be created or not (default: $DEFAULT_SQL)
-tv,--tomcat-version Specify the tomcat version (implies -w tomcat)
-d,--debug Enable Server and TCK appclient debug options (5005 and 5003)
-de,--debug-embedded Enable TCK embedded ejb debug options (port 5001)
-dh,--debug-harness Enable TCK harness debug options (port 5002)
-da,--debug-appclient Enable TCK appclient debug options (port 5003)
-dj,--debug-javatest Enable TCK javatest debug options (port 5004)
-ds,--debug-server Enable Server debug options (port 5005)
--connector deploy connectors for connector tests
-j,--jaxrs build jaxrs tck wars
-k,--kill Kill any java tck process that might be running
--reverse Generate jaxws jws reverse artifacts
-o,--option <option> Enable an option
-ol,--offline Run maven offline
-c,--clean Mvn clean
-tr,--temp-repo Mvn -Dmaven.repo.local=temp
-U,--update Mvn update snapshots
--source Source a script to change environment settings such as jdk version
--env Print the environment prior to running mvn
-nc,--no-colors Do not print in colors
-- Stop option processing
EOF
exit 1
}
if [ $# -lt 1 ]; then
usage
fi
echo "$(basename $0) $@"
JAVA_HOME=$JAVA_HOME
PATH=$PATH
tests=""
web="$DEFAULT_WEB"
sql="$DEFAULT_SQL"
profile="$DEFAULT_PROFILE"
args=""
options=""
env=""
nc=""
src=""
#tomcatVersion="-Dtomcat.version=6.0.32"
assertOptionArg() {
if [ "x$2" = "x" ]; then
die "Option '$1' requires an argument"
fi
}
appendOption() {
echo "Including options=$1"
if [ "x$options" = "x" ]; then
options="$1"
else
options="${options},$1"
fi
}
appendArgs() {
if [ "x$args" = "x" ]; then
args="$*"
else
args="$args $*"
fi
}
appendTests() {
if [ "x$tests" = "x" ]; then
tests="$1"
else
tests="${tests},$1"
fi
}
processOptions() {
while [ "x$1" != "x" ]; do
case "$1" in
-sql)
assertOptionArg $1 $2
sql=$2
shift
;;
-h|--help)
usage
;;
-w|--web)
assertOptionArg $1 $2
web="$2"; shift
;;
-tv|--tomcat-version)
web="tomcat"
assertOptionArg $1 $2
tomcatVersion="-Dtomcat.version=$2"; shift
;;
-o|--option)
assertOptionArg $1 $2
appendOption "$2"; shift
;;
-d|--debug)
appendOption "debug"
appendOption "appclient-debug"
;;
-da|--debug-appclient)
appendOption "appclient-debug"
;;
-de|--debug-embedded)
appendOption "embedded-debug"
;;
-dh|--debug-harness)
appendOption "harness-debug"
;;
-dj|--debug-javatest)
appendOption "javatest-debug"
;;
-ds|--debug-server)
appendOption "debug"
;;
--connector)
appendArgs "-Dconnector=true"
;;
-j|--jaxrs)
appendArgs "-Djaxrs=true"
;;
--reset-persistence)
appendArgs "-Dreset.persistence=true"
;;
--interop)
appendArgs "-Dinterop=true"
;;
--ee91)
appendArgs "-Djakartaee=9.1"
;;
--reverse)
appendArgs "-Dreverse=true"
;;
-ol|--offline)
appendArgs "-o"
;;
-U|--update)
appendArgs "-U"
;;
-c|--clean)
appendArgs "clean install"
;;
-tr|--temp-repo)
appendArgs "-Dmaven.repo.local=repo"
;;
--source)
assertOptionArg "$1" "$2"
src="$2"
shift
;;
--env)
env=1
;;
-nc|--no-colors)
nc=1
;;
-k|--kill)
killPrevious=1
;;
--)
shift
appendArgs "$*"
break
;;
# Collect extra options to pass on to mvn
-*)
appendArgs "$1"
;;
# Non-option args are tests
*)
appendTests "$1"
;;
esac
shift
done
}
if [ "x$RUNTESTS_OPTIONS" != "x" ]; then
echo "Including options from environment: $RUNTESTS_OPTIONS"
processOptions $RUNTESTS_OPTIONS
fi
processOptions "$@"
# Validate web
case "$web" in
tomee-plus|tomee-plume|tomee|tomcat|none)
profile="web-profile"
true
;;
tomcat-web)
profile="web"
appendOption "web-profile"
true
;;
*)
echo "Unknown web container: $web"
exit 3
;;
esac
rm -fr derbydb
unzip -q derbydb.zip
#sql=skip
# Append options if any
if [ "x$options" != "x" ]; then
appendArgs "-Doptions=$options"
fi
# Make sure a test was selected
if [ "x$tests" = "x" ]; then
usage
fi
# Pick the mvn executable to use
if [ "x$M2_HOME" = "x" ]; then
mvn="mvn"
else
mvn="$M2_HOME/bin/mvn"
fi
if [ -n "$tomcatVersion" ]; then
ant -f download.xml $tomcatVersion
fi
if [ "$killPrevious" != "" ]; then
echo "Killing old processes $(ps ax | grep "[j]ava.*$PWD" | cut -c 1-5 )"
ps ax | grep "[j]ava.*$PWD" | cut -c 1-5 | xargs kill -9
sleep 5
ps ax | grep "[j]ava.*$PWD"
fi
if [ -z $nc ]; then
export BOLD=`tput bold`
export UNDERLINE_ON=`tput smul`
export UNDERLINE_OFF=`tput rmul`
export TEXT_BLACK=`tput setaf 0`
export TEXT_RED=`tput setaf 1`
export TEXT_GREEN=`tput setaf 2`
export TEXT_YELLOW=`tput setaf 3`
export TEXT_BLUE=`tput setaf 4`
export TEXT_MAGENTA=`tput setaf 5`
export TEXT_CYAN=`tput setaf 6`
export TEXT_WHITE=`tput setaf 7`
export BACKGROUND_BLACK=`tput setab 0`
export BACKGROUND_RED=`tput setab 1`
export BACKGROUND_GREEN=`tput setab 2`
export BACKGROUND_YELLOW=`tput setab 3`
export BACKGROUND_BLUE=`tput setab 4`
export BACKGROUND_MAGENTA=`tput setab 5`
export BACKGROUND_CYAN=`tput setab 6`
export BACKGROUND_WHITE=`tput setab 7`
export RESET_FORMATTING=`tput sgr0`
fi
CONFIG=" -DassemblyId=$web -Dtests=$tests -Djavaee.level=$profile -Dwebcontainer=$web -Dsql=$sql"
echo ">>> config => $( echo "$CONFIG" | sed 's/ /\n/g')"
echo "" # just an empty line
[ ! -z "$src" ] && {
[ -f "$src" ] || {
echo "Cannot source file $src: file not found"
exit 1
}
source "$src"
}
[ ! -z $env ] && export
# printing the content of the 2 main directories
egrep '(javaee|jakarta).(ri|cts).home' ~/.m2/settings.xml | perl -pe 's,^ *|<[^>]+>,,g' | while read n; do echo $n; ls -l $n; done
# Fire up Maven to do the real work
if [ -z $nc ]; then
exec mvn -V --file "$DIRNAME/pom.xml" \
--batch-mode \
--errors \
$CONFIG \
$tomcatVersion \
$args | sed -e "s/\(\[INFO\]\ \-.*\)/${TEXT_BLUE}${BOLD}\1${RESET_FORMATTING}/g" \
-e "s/\(\[INFO\]\ BUILD SUCCESS.*\)/${BOLD}${TEXT_GREEN}\1${RESET_FORMATTING}/g" \
-e "s/\(\[INFO\]\ BUILD FAILURE\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}/g" \
-e "s/\(\[INFO\]\ .*\ FAILURE\ \[.*s]\)/${TEXT_RED}${BOLD}\1${RESET_FORMATTING}/g" \
-e "s/\(\[INFO\]\ .*\ SUCCESS\ \[.*s]\)/${TEXT_GREEN}${BOLD}\1${RESET_FORMATTING}/g" \
-e "s/\(\[INFO\]\ .*\ SKIPPED\)/${TEXT_YELLOW}${BOLD}\1${RESET_FORMATTING}/g" \
-e "s/\(\[INFO\]\ Building .*\)/${TEXT_CYAN}${BOLD}\1${RESET_FORMATTING}/g" \
-e "s/\(\[WARNING\].*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}/g" \
-e "s/\(\[ERROR\].*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}/g" \
-e "s/Tests run: \([^,]*\), Failures: \([^,]*\), Errors: \([^,]*\), Skipped: \([^,]*\)/${BOLD}${TEXT_GREEN}Tests run: \1${RESET_FORMATTING}, Failures: ${BOLD}${TEXT_RED}\2${RESET_FORMATTING}, Errors: ${BOLD}${TEXT_RED}\3${RESET_FORMATTING}, Skipped: ${BOLD}${TEXT_YELLOW}\4${RESET_FORMATTING}/g"
else
exec mvn -V --file "$DIRNAME/pom.xml" \
--batch-mode \
--errors \
$CONFIG \
$tomcatVersion \
$args
fi
# Make sure formatting is reset
echo -ne ${RESET_FORMATTING}