Skip to content

Commit 289aa7f

Browse files
committed
Merge branch of git://github.com/thebeline/php-curl-class into thebeline
* 'HelpfulerTravis' of git://github.com/thebeline/php-curl-class: Make Travis checks more helpfuler.
2 parents 7afa5fa + 1a3f399 commit 289aa7f

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

tests/script.sh

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
# Check syntax in php files.
22
find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec php -l {} \;
33

4+
errors=0
5+
46
# Run tests.
57
phpunit --configuration tests/phpunit.xml
68
if [[ "${?}" -ne 0 ]]; then
7-
exit 1
9+
((errors++))
810
fi
911

1012
# Enforce line ending consistency in php files.
1113
crlf_file=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec grep --files-with-matches $'\r' {} \;)
1214
if [[ ! -z "${crlf_file}" ]]; then
1315
echo "${crlf_file}" | perl -pe 's/(.*)/CRLF line terminators found in \1/'
14-
exit 1
16+
((errors++))
1517
fi
1618

1719
# Enforce indentation character consistency in php files.
1820
tab_char=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec grep --line-number -H --perl-regexp "\t" {} \;)
1921
if [[ ! -z "${tab_char}" ]]; then
2022
echo -e "${tab_char}" | perl -pe 's/^(.*)$/Tab character found in \1/'
21-
exit 1
23+
((errors++))
2224
fi
2325

2426
# Enforce indentation consistency in php files.
@@ -53,41 +55,47 @@ if [[ "${TRAVIS_PHP_VERSION}" != "hhvm" ]]; then
5355
invalid_indentation=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec bash -c 'find_invalid_indentation "{}"' \;)
5456
if [[ ! -z "${invalid_indentation}" ]]; then
5557
echo "${invalid_indentation}"
56-
exit 1
58+
((errors++))
5759
fi
5860
fi
5961

6062
# Prohibit trailing whitespace in php files.
6163
trailing_whitespace=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec egrep --line-number -H " +$" {} \;)
6264
if [[ ! -z "${trailing_whitespace}" ]]; then
6365
echo -e "${trailing_whitespace}" | perl -pe 's/^(.*)$/Trailing whitespace found in \1/'
64-
exit 1
66+
((errors++))
6567
fi
6668

6769
# Prohibit long lines in php files.
6870
long_lines=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec awk '{print FILENAME":"NR" "length}' {} \; | awk '$2 > 120')
6971
if [[ ! -z "${long_lines}" ]]; then
7072
echo -e "${long_lines}" | perl -pe 's/^(.*)$/Long lines found in \1/'
71-
exit 1
73+
((errors++))
7274
fi
7375

7476
# Prohibit @author in php files.
7577
at_author=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec egrep --line-number -H "@author" {} \;)
7678
if [[ ! -z "${at_author}" ]]; then
7779
echo -e "${at_author}" | perl -pe 's/^(.*)$/\@author found in \1/'
78-
exit 1
80+
((errors++))
7981
fi
8082

8183
# Prohibit screaming caps notation in php files.
8284
caps=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec egrep --color=always --line-number -H -e "FALSE[^']" -e "NULL" -e "TRUE" {} \;)
8385
if [[ ! -z "${caps}" ]]; then
8486
echo -e "${caps}" | perl -pe 's/^(.*)$/All caps found in \1/'
85-
exit 1
87+
((errors++))
8688
fi
8789

8890
# Require identical comparison operators (===, not ==) in php files.
8991
equal=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec egrep --color=always --line-number -H "[^!=]==[^=]" {} \;)
9092
if [[ ! -z "${equal}" ]]; then
9193
echo -e "${equal}" | perl -pe 's/^(.*)$/Non-identical comparison operator found in \1/'
92-
exit 1
94+
((errors++))
9395
fi
96+
97+
if [ $errors -eq 0 ]; then
98+
exit 0
99+
else
100+
exit 1
101+
fi

0 commit comments

Comments
 (0)