-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.sh
executable file
·46 lines (36 loc) · 1011 Bytes
/
test.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
#!/usr/bin/env bash
DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
DEFAULT_TEST_DIR=test/unit
usage_error() {
echo >&2 "$(basename $0): $1"
exit 2
}
if [ "$#" != 0 ]; then
EOL=$(printf '\1\3\3\7')
set -- "$@" "$EOL"
while [ "$1" != "$EOL" ]; do
opt="$1"
shift
case "$opt" in
-c | --coverage) coverage='-dxdebug.mode=coverage' ;;
-*) usage_error "unknown option: '$opt'" ;;
esac
done
shift
fi
for d in */; do
d=${d%?}
if [[ "$d" == 'vendor' || "$d" == 'coverage' ]]; then
continue
fi
testDir=$(grep test-suites-path "$DIR/$d/.github/workflows" -R | awk '{print $NF}')
if [[ -z "$testDir" ]]; then
testDir="$DEFAULT_TEST_DIR"
fi
if [ ! -d "$DIR/$d/$testDir" ]; then
continue
fi
cp "$DIR/phpunit.xml.dist" "$DIR/phpunit.xml"
sed -ie "s/\*/$d/g" "$DIR/phpunit.xml"
php -derror_reporting=24575 $coverage vendor/bin/phpunit --coverage-php "coverage/$d.php" --log-teamcity "log/$d/teamcity.txt" "$d/$testDir"
done