-
Notifications
You must be signed in to change notification settings - Fork 107
/
phpunit.sh
executable file
·68 lines (59 loc) · 1.77 KB
/
phpunit.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
#!/bin/bash
#
# Tool for run unit test for swoft components
#
# import common functions
source "$(dirname $0)/script/shells/common-func.sh"
binName="./$(basename $0)"
if [[ -z "$1" ]] || [[ "$1" == "-h" ]]; then
echo "Use for run phpunit for swoft components."
echo ""
echo "Usage:"
echo " $binName NAME(S) Run phpunit for the given component in the src/NAME"
echo " $binName all Run phpunit for all components at the src/*"
echo " $binName nodb Run phpunit for all component, but exclude 'db' and 'redis'"
echo ""
echo "Example:"
echo " $binName db Run phpunit for 'db' component"
echo " $binName db event Run phpunit for 'db' and 'event' component"
echo ""
exit
fi
# for one or multi component
if [[ "$1" != "all" ]]; then
if [[ "$1" == "nodb" ]]; then
components=$(ls src | grep -v db | grep -v redis)
else
components=$*
fi
else
components=$(ls src/)
fi
colored_text "Will test components:"
echo "${components}"
echo ""
# do run phpunit
# php run.php -c src/annotation/phpunit.xml
# set -ex
for lbName in ${components} ; do
if [[ "${lbName}" == "component" ]]; then
colored_text "======> Testing the【component】"
yellow_text "> php run.php -c phpunit.xml"
php run.php -c phpunit.xml
else
if [[ ! -d "src/${lbName}" ]]; then
cyan_text "!! Skip invalid component: ${lbName}"
else
colored_text "======> Testing the component【${lbName}】"
yellow_text "> php run.php -c src/${lbName}/phpunit.xml"
php run.php -c src/${lbName}/phpunit.xml
fi
fi
CODE=$?
# shellcheck disable=SC2181
if [ "$CODE" != "0" ]; then
exit 1
fi
echo ""
done
cyan_text ":) Test Completed!"