From 8161fa961102134bcf961cf2ed4a6115255488d0 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 12 Jul 2018 20:03:48 +0200 Subject: [PATCH] Pull out tests from syntax checks --- Hooks/delegator.sh | 3 ++- Hooks/syntax.sh | 12 ------------ Hooks/tests.sh | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 Hooks/tests.sh diff --git a/Hooks/delegator.sh b/Hooks/delegator.sh index 64b4e2b..2a7b804 100644 --- a/Hooks/delegator.sh +++ b/Hooks/delegator.sh @@ -2,4 +2,5 @@ . ${rootpath}/Build/Hooks/logging.sh . ${rootpath}/Build/Hooks/syntax.sh -. ${rootpath}/Build/Hooks/filename.sh \ No newline at end of file +. ${rootpath}/Build/Hooks/filename.sh +. ${rootpath}/Build/Hooks/tests.sh \ No newline at end of file diff --git a/Hooks/syntax.sh b/Hooks/syntax.sh index e5c9ef5..d7b4263 100644 --- a/Hooks/syntax.sh +++ b/Hooks/syntax.sh @@ -24,18 +24,6 @@ if [[ "$FILE" =~ ^.+(php)$ ]]; then echo -e "\e[1;31m\tMess Detector error.\e[0m" >&2 exit 1 fi - - # phan - ${rootpath}/vendor/bin/phan -k ${rootpath}/Build/Config/phan.php -f $FILE - if [ $? -ne 0 ]; then - echo -e "\e[1;31m\tPhan warning.\e[0m" >&2 - fi - - # phpstan - php -d memory_limit=4G ${rootpath}/vendor/bin/phpstan analyse --autoload-file=${rootpath}/phpOMS/Autoloader.php -l 7 -c ${rootpath}/Build/Config/phpstan.neon $FILE - if [ $? -ne 0 ]; then - echo -e "\e[1;31m\tPhp stan warning.\e[0m" >&2 - fi fi fi diff --git a/Hooks/tests.sh b/Hooks/tests.sh new file mode 100644 index 0000000..e0e38fe --- /dev/null +++ b/Hooks/tests.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +git diff --cached --name-only | while read FILE; do + +if [[ "$FILE" =~ ^.+(php)$ ]]; then + if [[ -f $FILE ]]; then + # phan + ${rootpath}/vendor/bin/phan -k ${rootpath}/Build/Config/phan.php -f $FILE + if [ $? -ne 0 ]; then + echo -e "\e[1;31m\tPhan warning.\e[0m" >&2 + fi + + # phpstan + php -d memory_limit=4G ${rootpath}/vendor/bin/phpstan analyse --autoload-file=${rootpath}/phpOMS/Autoloader.php -l 7 -c ${rootpath}/Build/Config/phpstan.neon $FILE + if [ $? -ne 0 ]; then + echo -e "\e[1;31m\tPhp stan warning.\e[0m" >&2 + fi + fi +fi + +done || exit $?