-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_functional_tests
More file actions
executable file
·117 lines (102 loc) · 3.64 KB
/
run_functional_tests
File metadata and controls
executable file
·117 lines (102 loc) · 3.64 KB
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
#!/bin/sh
ulimit -c 0
set -e
uname=`uname`
if [ "$uname" = FreeBSD ]; then
MAKE=gmake
else
MAKE=make
fi
rm -f mutinack.jar && ant jar_enhanced
if [ "$uname" = FreeBSD -o "$uname" = Darwin ]; then
TIME=time
else
TIME=""
fi
./regenerate_SSL_files
#This script assumes the presence of a Makefile in directory functional_tests,
#with targets all_failed (to re-run failed that were marked in a previous run
#as having failed) and all. Target all_failed is invoked first; if it fails,
#and BAIL_IF_FAILED_TESTS_NOT_FIXED is equal to 1, the script exits with an
#error. If not, target all is invoked next.
#Set to 1 to get quick notification that failed tests have not been
#fixed (the tradeoff is not knowing if some tests that were passing are now
#failing).
BAIL_IF_FAILED_TESTS_NOT_FIXED=1
#make -j parameter
N_PARALLEL_JOBS=2
#NailGun server seems to require a kill -9 to exit
trap 'code=$?; ([ "$server_pid" != "" ] && kill $server_pid 2>/dev/null && kill $server_pid 2>/dev/null ); ([ "$worker_pids" != "" ] && kill $worker_pids 2>/dev/null ); processes="$nailgun_server_pid"; ([ "$processes" != "" ] && kill -9 $processes 2>/dev/null ) || true; exit $code' INT QUIT TERM EXIT
nailgun_port=`./getAvailablePort.py 2113`
export nailgun_port
server_pid=`./run_server localhost/mutinackTesting${nailgun_port}` || (echo "Could not start Mutinack server" && false)
echo Started server $server_pid
nailgun_server_pid=`./run_nailgun_server ${nailgun_port}` || (echo "Could not start NailGun server" && false)
echo Started nailgun server $nailgun_server_pid
worker_pids=''
for i in `seq 1 $N_PARALLEL_JOBS`
do
worker_pid=`./run_worker localhost/mutinackTesting${nailgun_port}` || (echo "Could not start Mutinack worker" && false)
echo Started worker $worker_pid
worker_pids=`echo $worker_pids $worker_pid`
done
GIT=true
#Uncomment line below to activate git failed test tracking functionality
#GIT=git
update_repo () {
if [ ! -z "`${GIT} diff --shortstat 2> /dev/null | tail -n1`" ]
then
(${GIT} branch -u origin/`${GIT} rev-parse --abbrev-ref HEAD` && ${GIT} config --global push.default simple && ${GIT} stash && ${GIT} fetch && (${GIT} merge || ${GIT} merge -X ours) && (${GIT} stash pop > /dev/null 2>&1) && (${GIT} ls-files --deleted -z | xargs -0 ${GIT} rm) && (${GIT} commit -m "Automatic update to failed test record: $1" > /dev/null 2>&1 || /usr/bin/true) && ${GIT} push) || echo "Error in processing test record update"
fi
}
mkdir -p target && cd target && ( [ ! -d classes ] && ln -f -s ../bin classes || true) && cd ..
cp -p mutinack.jar functional_tests/
cd functional_tests
ln -s -f ../nailgun/ng
${MAKE} clean
for target in all_failed all
do
for assertions in "true" "false"
do
if [ "$target" = "all" ]
then
${MAKE} clean_results
fi
export COSTLY_ASSERTIONS="$assertions"
if [ "$assertions" = "false" ]
then
export OUTPUT_OPTION="-outputSerializedTo /dev/null"
else
export OUTPUT_OPTION=""
fi
counter=0
while true
do
if [ `(${TIME} ${MAKE} -k -j${N_PARALLEL_JOBS} ${target}_results 1>&2 && ${MAKE} -k -j${N_PARALLEL_JOBS} ${target}_checks 1>&2 ) && echo 1 || echo 0` -eq 1 ]
then
#success
break
fi
counter=`expr $counter + 1`
if [ $counter -eq 1 ]
then
if [ "$target" = "all_failed" -a $BAIL_IF_FAILED_TESTS_NOT_FIXED -ne 1 ]
then
break
fi
echo "Functional tests failed; giving up"
update_repo "ERROR: failed functional tests"
exit 1
fi
echo "Functional tests failed; trying again"
done
done
done
counter=`expr $counter + 1`
message="Functional tests passed"
if [ $counter -gt 1 ]
then
message="${message}; WARNING: success only after $counter tries"
fi
echo "$message"
update_repo "$message"