From 38ab61f3201f8d0deebbee1c4249acdcc2cac55b Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=98=A4=ED=98=95=EC=84=9D/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Thu, 25 Oct 2018 16:18:43 +0900 Subject: [PATCH] Check invalid format-checker exit (#3327) Check invalid format-checker exit and return fail Signed-off-by: Hyeongseok Oh --- scripts/command/format-checker.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/command/format-checker.sh b/scripts/command/format-checker.sh index 989d5fd..9c22067 100755 --- a/scripts/command/format-checker.sh +++ b/scripts/command/format-checker.sh @@ -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 -- 2.7.4