-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
Copy pathrun-tests.sh
executable file
·77 lines (68 loc) · 1.72 KB
/
run-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
#!/bin/sh -e
__CURRENT__=`pwd`
__DIR__=$(cd "$(dirname "$0")";pwd)
[ -z "${SWOOLE_BRANCH}" ] && export SWOOLE_BRANCH="master"
#-------------PHPT-------------
cd ${__DIR__} && cd ../tests/
# initialization
echo "" && echo "⭐️ Initialization for tests..." && echo ""
./init
echo ""
# debug
for debug_file in ${__DIR__}/debug/*.php
do
if test -f "${debug_file}";then
debug_file_basename="`basename ${debug_file}`"
echo "" && echo "====== RUN ${debug_file_basename} ======" && echo ""
php "${debug_file}"
echo "" && echo "========================================" && echo ""
fi
done
# run tests @params($1=list_file, $1=options)
run_tests(){
./start.sh \
"`tr '\n' ' ' < ${1} | xargs`" \
-w ${1} \
${2}
}
has_failures(){
cat tests.list
}
should_exit_with_error(){
if [ "${SWOOLE_BRANCH}" = "valgrind" ]; then
set +e
find ./ -type f -name "*.mem"
set -e
else
has_failures
fi
}
touch tests.list
trap "rm -f tests.list; echo ''; echo '⌛ Done on '`date "+%Y-%m-%d %H:%M:%S"`;" EXIT
echo "" && echo "🌵️️ Current branch is ${SWOOLE_BRANCH}" && echo ""
if [ "${SWOOLE_BRANCH}" = "valgrind" ]; then
dir="base"
options="-m"
else
dir="swoole_*"
options=""
fi
echo "${dir}" > tests.list
for i in 1 2 3 4 5
do
if [ "`has_failures`" ]; then
if [ ${i} -gt "1" ]; then
sleep ${i}
echo "" && echo "😮 Retry failed tests#${i}:" && echo ""
fi
cat tests.list
timeout=`echo | expr ${i} \* 15 + 15`
options="${options} --set-timeout ${timeout}"
run_tests tests.list "${options}"
else
break
fi
done
if [ "`should_exit_with_error`" ]; then
exit 255
fi