-
Notifications
You must be signed in to change notification settings - Fork 107
/
coverage.sh
executable file
·66 lines (58 loc) · 1.96 KB
/
coverage.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
#!/usr/bin/env bash
#
# Tool for run unit test and display coverage information
#
# 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 and output coverage 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
echo "======> Testing the【components】"
yellow_text "> phpdbg -dauto_globals_jit=Off -qrr run.php --coverage-text -c phpunit.xml"
phpdbg -dauto_globals_jit=Off -qrr run.php --coverage-text -c phpunit.xml
else
if [[ ! -d "src/${lbName}" ]]; then
cyan_text "!! Skip invalid component: ${lbName}"
else
echo "======> Testing the component【${lbName}】"
yellow_text "> phpdbg -dauto_globals_jit=Off -qrr run.php --coverage-text -c src/${lbName}/phpunit.xml"
phpdbg -dauto_globals_jit=Off -qrr run.php --coverage-text -c src/${lbName}/phpunit.xml
fi
fi
CODE=$?
# shellcheck disable=SC2181
if [ "$CODE" != "0" ]; then
exit 1
fi
done
cyan_text "\nTest Completed!"