|
1 | 1 | #!/usr/bin/env bash |
2 | 2 |
|
3 | 3 | # by default we execute the end-to-end encryption tests |
4 | | -if [[ -z "${END_TO_END_ENCRYPTION}" ]] |
5 | | -then |
| 4 | +if [[ -z "${END_TO_END_ENCRYPTION}" ]]; then |
6 | 5 | END_TO_END_ENCRYPTION="1" |
7 | 6 | fi |
8 | 7 |
|
9 | 8 | # by default we execute the server-side encryption tests |
10 | | -if [[ -z "${SERVER_SIDE_ENCRYPTION}" ]] |
11 | | -then |
| 9 | +if [[ -z "${SERVER_SIDE_ENCRYPTION}" ]]; then |
12 | 10 | SERVER_SIDE_ENCRYPTION="1" |
13 | 11 | fi |
14 | 12 |
|
15 | 13 | # check if git is installed |
16 | | -if [[ ! -x "$(command -v git)" ]] |
17 | | -then |
| 14 | +if [[ ! -x "$(command -v git)" ]]; then |
18 | 15 | echo "ERROR: git is not installed." >&2 |
19 | 16 | echo "ERROR: Try installing it with: brew install git" >&2 |
20 | 17 | exit 1 |
21 | 18 | fi |
22 | 19 |
|
23 | 20 | # check if php is installed |
24 | | -if [[ ! -x "$(command -v php)" ]] |
25 | | -then |
| 21 | +if [[ ! -x "$(command -v php)" ]]; then |
26 | 22 | echo "ERROR: php is not installed." >&2 |
27 | 23 | echo "ERROR: Try installing it with: brew install php" >&2 |
28 | 24 | exit 2 |
29 | 25 | fi |
30 | 26 |
|
31 | 27 | # check if phpunit is installed |
32 | | -if [[ ! -x "$(command -v phpunit)" ]] |
33 | | -then |
| 28 | +if [[ ! -x "$(command -v phpunit)" ]]; then |
34 | 29 | echo "ERROR: phpunit is not installed." >&2 |
35 | 30 | echo "ERROR: Try installing it with: brew install phpunit" >&2 |
36 | 31 | exit 3 |
37 | 32 | fi |
38 | 33 |
|
39 | 34 | # check if xdebug is installed |
40 | 35 | XDEBUG_OUTPUT=$(php -m -c 2>/dev/null | grep --quiet Xdebug) |
41 | | -if [[ "$?" -ne "0" ]] |
42 | | -then |
| 36 | +if [[ "$?" -ne "0" ]]; then |
43 | 37 | echo "ERROR: xdebug is not installed." >&2 |
44 | 38 | echo "ERROR: Try installing it with: pecl install xdebug" >&2 |
45 | 39 | exit 4 |
46 | 40 | fi |
47 | 41 |
|
48 | | -if [[ "${END_TO_END_ENCRYPTION}" -gt "0" ]] |
49 | | -then |
| 42 | +if [[ "${END_TO_END_ENCRYPTION}" -gt "0" ]]; then |
50 | 43 | # execute phpunit for the end-to-end encryption |
51 | 44 | echo "===== END-TO-END ENCRYPTION =====" |
52 | 45 | echo |
53 | 46 |
|
54 | 47 | # check if the test data repository has been checked out |
55 | 48 | echo "Preparing the test data for the end-to-end encryption, this could take a while..." |
56 | | - if [[ -d ./tests/data/end-to-end-encryption ]] |
57 | | - then |
| 49 | + if [[ -d ./tests/data/end-to-end-encryption ]]; then |
58 | 50 | git -C ./tests/data/end-to-end-encryption pull >/dev/null 2>&1 |
59 | 51 | else |
60 | 52 | git clone https://github.com/nextcloud/end-to-end-encryption-testdata ./tests/data/end-to-end-encryption >/dev/null 2>&1 |
61 | 53 | fi |
62 | | - if [[ "$?" -ne "0" ]] |
63 | | - then |
| 54 | + if [[ "$?" -ne "0" ]]; then |
64 | 55 | echo "ERROR: Preparing the test data for the end-to-end encryption failed." >&2 |
65 | 56 | exit 5 |
66 | 57 | fi |
67 | 58 |
|
68 | 59 | # separate output |
69 | 60 | echo |
70 | 61 |
|
71 | | - XDEBUG_MODE=coverage phpunit -c ./phpunit.end-to-end-encryption.xml --coverage-html ./tests/cache/end-to-end-encryption/ --coverage-text |
| 62 | + # filter tests |
| 63 | + if [[ -n "${1}" ]]; then |
| 64 | + XDEBUG_MODE=coverage phpunit -c ./phpunit.end-to-end-encryption.xml --coverage-html ./tests/cache/end-to-end-encryption/ --coverage-text "--filter=${1}" |
| 65 | + else |
| 66 | + XDEBUG_MODE=coverage phpunit -c ./phpunit.end-to-end-encryption.xml --coverage-html ./tests/cache/end-to-end-encryption/ --coverage-text |
| 67 | + fi |
72 | 68 | TEMP="$?" |
73 | 69 |
|
74 | 70 | # only proceed if no errors occured |
75 | | - if [[ "$TEMP" -ne "0" ]] |
76 | | - then |
| 71 | + if [[ "$TEMP" -ne "0" ]]; then |
77 | 72 | echo "ERROR: error during phpunit run for the end-to-end encryption" >&2 |
78 | 73 | exit "$TEMP" |
79 | 74 | fi |
80 | 75 | fi |
81 | 76 |
|
82 | | -if [[ "${SERVER_SIDE_ENCRYPTION}" -gt "0" ]] |
83 | | -then |
| 77 | +if [[ "${SERVER_SIDE_ENCRYPTION}" -gt "0" ]]; then |
84 | 78 | # execute phpunit for the server-side encryption |
85 | 79 | echo "===== SERVER-SIDE ENCRYPTION =====" |
86 | 80 | echo |
87 | 81 |
|
88 | 82 | # check if the test data repository has been checked out |
89 | 83 | echo "Preparing the test data for the server-side encryption, this could take a while..." |
90 | | - if [[ -d ./tests/data/server-side-encryption ]] |
91 | | - then |
| 84 | + if [[ -d ./tests/data/server-side-encryption ]]; then |
92 | 85 | git -C ./tests/data/server-side-encryption pull >/dev/null 2>&1 |
93 | 86 | else |
94 | 87 | git clone https://github.com/nextcloud/server-side-encryption-testdata ./tests/data/server-side-encryption >/dev/null 2>&1 |
95 | 88 | fi |
96 | | - if [[ "$?" -ne "0" ]] |
97 | | - then |
| 89 | + if [[ "$?" -ne "0" ]]; then |
98 | 90 | echo "ERROR: Preparing the test data for the server-side encryption failed." >&2 |
99 | 91 | exit 6 |
100 | 92 | fi |
101 | 93 |
|
102 | 94 | # separate output |
103 | 95 | echo |
104 | 96 |
|
105 | | - XDEBUG_MODE=coverage phpunit -c ./phpunit.server-side-encryption.xml --coverage-html ./tests/cache/server-side-encryption/ --coverage-text |
| 97 | + # filter tests |
| 98 | + if [[ -n "${1}" ]]; then |
| 99 | + XDEBUG_MODE=coverage phpunit -c ./phpunit.server-side-encryption.xml --coverage-html ./tests/cache/server-side-encryption/ --coverage-text "--filter=${1}" |
| 100 | + else |
| 101 | + XDEBUG_MODE=coverage phpunit -c ./phpunit.server-side-encryption.xml --coverage-html ./tests/cache/server-side-encryption/ --coverage-text |
| 102 | + fi |
106 | 103 | TEMP="$?" |
107 | 104 |
|
108 | 105 | # only proceed if no errors occured |
109 | | - if [[ "$TEMP" -ne "0" ]] |
110 | | - then |
| 106 | + if [[ "$TEMP" -ne "0" ]]; then |
111 | 107 | echo "ERROR: error during phpunit run for the server-side encryption" >&2 |
112 | 108 | exit "$TEMP" |
113 | 109 | fi |
|
0 commit comments