diff --git a/tools/check_log_error.py b/tools/check_log_error.py index 4190f0511..6cc03b297 100755 --- a/tools/check_log_error.py +++ b/tools/check_log_error.py @@ -24,6 +24,7 @@ import sys import re +import warnings lines = '' sucess_regx = 'LOG\(ERROR\)[^}]+return MLUOP_STATUS_SUCCESS;' @@ -143,10 +144,10 @@ def helper(func, reg): "MLUOP_STATUS_EXECUTION_FAILED" ) == -1 and temp[res2.span()[1]:].find( "MLUOP_STATUS_NOT_SUPPORTED") == -1: - print( + warnings.warn( '-- the LOG(ERROR) may be not legal, please make sure have the correct return value' ) - print( + warnings.warn( '-- this is just a hint, if you confirm it is correct, you can ignore it' ) print(temp) @@ -168,7 +169,8 @@ def check(): def main(): if sys.argv[1].endswith(".mlu") or sys.argv[1].endswith(".cpp"): - getFile(sys.argv[1]) + getFile(sys.argv[1]) + print('check filename: %s.'%(sys.argv[1])) check() diff --git a/tools/pre-commit b/tools/pre-commit index 48a0ae01e..dd780cdc5 100755 --- a/tools/pre-commit +++ b/tools/pre-commit @@ -11,7 +11,8 @@ bangc_gtest_json_file="jsoncppDist/" bangc_exclude_list=${bangc_gtest_json_file} if [[ $# -eq 1 ]]; then - filenames=$(git diff --name-only ${1} \ + filenames=$(git diff --diff-filter=A --diff-filter=C --diff-filter=M \ + --diff-filter=R --diff-filter=T --name-only ${1} \ | grep -v ${bangc_exclude_list} \ | grep -E ${bangc_check_list}) else @@ -148,6 +149,9 @@ fi echo "-- [check_log_error] Using tools/check_log_error.py to check the LOG(error)" for i in $filenames; do python tools/check_log_error.py $i + if [[ $? -ne 0 ]]; then + exit 1 + fi done if [[ $# -eq 1 ]]; then