From 1a3f39924525730c2937b257b77433592993a954 Mon Sep 17 00:00:00 2001 From: Mike Mulligan Date: Mon, 28 Mar 2016 12:25:58 -0400 Subject: [PATCH 1/2] Make Travis checks more helpfuler. --- tests/script.sh | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/tests/script.sh b/tests/script.sh index 1b49763..dc62937 100755 --- a/tests/script.sh +++ b/tests/script.sh @@ -1,24 +1,26 @@ # Check syntax in php files. find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec php -l {} \; +errors=0 + # Run tests. phpunit --configuration tests/phpunit.xml if [[ "${?}" -ne 0 ]]; then - exit 1 + ((errors++)) fi # Enforce line ending consistency in php files. crlf_file=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec grep --files-with-matches $'\r' {} \;) if [[ ! -z "${crlf_file}" ]]; then echo "${crlf_file}" | perl -pe 's/(.*)/CRLF line terminators found in \1/' - exit 1 + ((errors++)) fi # Enforce indentation character consistency in php files. tab_char=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec grep --line-number -H --perl-regexp "\t" {} \;) if [[ ! -z "${tab_char}" ]]; then echo -e "${tab_char}" | perl -pe 's/^(.*)$/Tab character found in \1/' - exit 1 + ((errors++)) fi # Enforce indentation consistency in php files. @@ -53,7 +55,7 @@ if [[ "${TRAVIS_PHP_VERSION}" != "hhvm" ]]; then invalid_indentation=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec bash -c 'find_invalid_indentation "{}"' \;) if [[ ! -z "${invalid_indentation}" ]]; then echo "${invalid_indentation}" - exit 1 + ((errors++)) fi fi @@ -61,33 +63,39 @@ fi trailing_whitespace=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec egrep --line-number -H " +$" {} \;) if [[ ! -z "${trailing_whitespace}" ]]; then echo -e "${trailing_whitespace}" | perl -pe 's/^(.*)$/Trailing whitespace found in \1/' - exit 1 + ((errors++)) fi # Prohibit long lines in php files. long_lines=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec awk '{print FILENAME":"NR" "length}' {} \; | awk '$2 > 120') if [[ ! -z "${long_lines}" ]]; then echo -e "${long_lines}" | perl -pe 's/^(.*)$/Long lines found in \1/' - exit 1 + ((errors++)) fi # Prohibit @author in php files. at_author=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec egrep --line-number -H "@author" {} \;) if [[ ! -z "${at_author}" ]]; then echo -e "${at_author}" | perl -pe 's/^(.*)$/\@author found in \1/' - exit 1 + ((errors++)) fi # Prohibit screaming caps notation in php files. caps=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec egrep --color=always --line-number -H -e "FALSE[^']" -e "NULL" -e "TRUE" {} \;) if [[ ! -z "${caps}" ]]; then echo -e "${caps}" | perl -pe 's/^(.*)$/All caps found in \1/' - exit 1 + ((errors++)) fi # Require identical comparison operators (===, not ==) in php files. equal=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec egrep --color=always --line-number -H "[^!=]==[^=]" {} \;) if [[ ! -z "${equal}" ]]; then echo -e "${equal}" | perl -pe 's/^(.*)$/Non-identical comparison operator found in \1/' - exit 1 + ((errors++)) fi + +if [ $errors -eq 0 ]; then + exit 0 +else + exit 1 +fi \ No newline at end of file From 5c2aa6c663ddcf70b1bdc101ffd19841142c09e6 Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Mon, 28 Mar 2016 22:19:20 -0700 Subject: [PATCH 2/2] Remove tabs --- tests/script.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/script.sh b/tests/script.sh index dc62937..d625f5a 100755 --- a/tests/script.sh +++ b/tests/script.sh @@ -95,7 +95,7 @@ if [[ ! -z "${equal}" ]]; then fi if [ $errors -eq 0 ]; then - exit 0 + exit 0 else - exit 1 -fi \ No newline at end of file + exit 1 +fi