-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathphpunit.sh
executable file
·114 lines (98 loc) · 3.12 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
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
#!/usr/bin/env bash
# by default we execute the end-to-end encryption tests
if [[ -z "${END_TO_END_ENCRYPTION}" ]]
then
END_TO_END_ENCRYPTION="1"
fi
# by default we execute the server-side encryption tests
if [[ -z "${SERVER_SIDE_ENCRYPTION}" ]]
then
SERVER_SIDE_ENCRYPTION="1"
fi
# check if git is installed
if [[ ! -x "$(command -v git)" ]]
then
echo "ERROR: git is not installed." >&2
echo "ERROR: Try installing it with: brew install git" >&2
exit 1
fi
# check if php is installed
if [[ ! -x "$(command -v php)" ]]
then
echo "ERROR: php is not installed." >&2
echo "ERROR: Try installing it with: brew install php" >&2
exit 2
fi
# check if phpunit is installed
if [[ ! -x "$(command -v phpunit)" ]]
then
echo "ERROR: phpunit is not installed." >&2
echo "ERROR: Try installing it with: brew install phpunit" >&2
exit 3
fi
# check if xdebug is installed
XDEBUG_OUTPUT=$(php -m -c 2>/dev/null | grep --quiet Xdebug)
if [[ "$?" -ne "0" ]]
then
echo "ERROR: xdebug is not installed." >&2
echo "ERROR: Try installing it with: pecl install xdebug" >&2
exit 4
fi
if [[ "${END_TO_END_ENCRYPTION}" -gt "0" ]]
then
# execute phpunit for the end-to-end encryption
echo "===== END-TO-END ENCRYPTION ====="
echo
# check if the test data repository has been checked out
echo "Preparing the test data for the end-to-end encryption, this could take a while..."
if [[ -d ./tests/data/end-to-end-encryption ]]
then
git -C ./tests/data/end-to-end-encryption pull >/dev/null 2>&1
else
git clone https://github.com/nextcloud/end-to-end-encryption-testdata ./tests/data/end-to-end-encryption >/dev/null 2>&1
fi
if [[ "$?" -ne "0" ]]
then
echo "ERROR: Preparing the test data for the end-to-end encryption failed." >&2
exit 5
fi
# separate output
echo
XDEBUG_MODE=coverage phpunit -c ./phpunit.end-to-end-encryption.xml --coverage-html ./tests/cache/end-to-end-encryption/ --coverage-text
TEMP="$?"
# only proceed if no errors occured
if [[ "$TEMP" -ne "0" ]]
then
echo "ERROR: error during phpunit run for the end-to-end encryption" >&2
exit "$TEMP"
fi
fi
if [[ "${SERVER_SIDE_ENCRYPTION}" -gt "0" ]]
then
# execute phpunit for the server-side encryption
echo "===== SERVER-SIDE ENCRYPTION ====="
echo
# check if the test data repository has been checked out
echo "Preparing the test data for the server-side encryption, this could take a while..."
if [[ -d ./tests/data/server-side-encryption ]]
then
git -C ./tests/data/server-side-encryption pull >/dev/null 2>&1
else
git clone https://github.com/nextcloud/server-side-encryption-testdata ./tests/data/server-side-encryption >/dev/null 2>&1
fi
if [[ "$?" -ne "0" ]]
then
echo "ERROR: Preparing the test data for the server-side encryption failed." >&2
exit 6
fi
# separate output
echo
XDEBUG_MODE=coverage phpunit -c ./phpunit.server-side-encryption.xml --coverage-html ./tests/cache/server-side-encryption/ --coverage-text
TEMP="$?"
# only proceed if no errors occured
if [[ "$TEMP" -ne "0" ]]
then
echo "ERROR: error during phpunit run for the server-side encryption" >&2
exit "$TEMP"
fi
fi