Check invalid format-checker exit (#3327)
author오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Thu, 25 Oct 2018 07:18:43 +0000 (16:18 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 25 Oct 2018 07:18:43 +0000 (16:18 +0900)
Check invalid format-checker exit and return fail

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
scripts/command/format-checker.sh

index 989d5fd..9c22067 100755 (executable)
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+INVALID_EXIT=0
+
 pushd () {
     command pushd "$@" > /dev/null
 }
@@ -62,6 +64,10 @@ check_cpp_files() {
             CPP_FILES_TO_CHECK=${ARR[*]}
             if [[ ${#CPP_FILES_TO_CHECK} -ne 0 ]]; then
                 clang-format-3.9 -i $CPP_FILES_TO_CHECK
+                EXIT_CODE=$?
+                if [[ $EXIT_CODE -ne 0 ]]; then
+                    INVALID_EXIT=$EXIT_CODE
+                fi
             fi
         popd
     done
@@ -85,6 +91,10 @@ check_python_files() {
             PYTHON_FILES_TO_CHECK=${ARR[*]}
             if [[ ${#PYTHON_FILES_TO_CHECK} -ne 0 ]]; then
                 yapf -i --style='{based_on_style: pep8, column_limit: 90}' $PYTHON_FILES_TO_CHECK
+                EXIT_CODE=$?
+                if [[ $EXIT_CODE -ne 0 ]]; then
+                    INVALID_EXIT=$EXIT_CODE
+                fi
             fi
         popd
     done
@@ -126,7 +136,7 @@ fi
 git diff --ignore-submodules > format.patch
 PATCHFILE_SIZE=$(stat -c%s format.patch)
 
-if [[ -z "${CRCHECK}" ]] && [[ $PATCHFILE_SIZE -eq 0 ]]; then
+if [[ -z "${CRCHECK}" ]] && [[ $PATCHFILE_SIZE -eq 0 ]] && [[ $INVALID_EXIT -eq 0 ]]; then
     echo "[PASSED] Format checker succeed."
     exit 0
 fi
@@ -142,4 +152,8 @@ if [[ $PATCHFILE_SIZE -ne 0 ]]; then
     echo "[FAILED] Format checker failed and update code to follow convention."
     echo "         You can find changes in format.patch"
 fi
+
+if [[ $INVALID_EXIT -ne 0 ]]; then
+    echo "[[FAILED] Invalid format checker exit."
+fi
 exit 1