From 266106da7559a2ff1c38963b4a79f0511ca7d1ba Mon Sep 17 00:00:00 2001 From: Chen Weihang Date: Fri, 14 Feb 2020 10:41:29 +0800 Subject: [PATCH] Fix mismatch with plus sign in the line (#22588) * reproduce match error, test=develop, test=document_fix * fix mismatch error, test=develop, test=document_fix --- paddle/fluid/platform/enforce_test.cc | 6 ++++-- tools/check_api_approvals.sh | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/paddle/fluid/platform/enforce_test.cc b/paddle/fluid/platform/enforce_test.cc index f1f24bb920..7e1f62addf 100644 --- a/paddle/fluid/platform/enforce_test.cc +++ b/paddle/fluid/platform/enforce_test.cc @@ -69,7 +69,8 @@ TEST(ENFORCE_EQ, NO_EXTRA_MSG_FAIL) { int a = 2; bool caught_exception = false; try { - PADDLE_ENFORCE_EQ(a, 1 + 3); + PADDLE_ENFORCE_EQ(a, 1 + 3, paddle::platform::errors::InvalidArgument( + "the result is not equal correct result.")); } catch (paddle::platform::EnforceNotMet& error) { caught_exception = true; std::string ex_msg = error.what(); @@ -83,7 +84,8 @@ TEST(ENFORCE_EQ, EXTRA_MSG_FAIL) { int a = 2; bool caught_exception = false; try { - PADDLE_ENFORCE_EQ(a, 1 + 3, "%s size not match", "their"); + PADDLE_ENFORCE_EQ(a, 1 + 3, paddle::platform::errors::InvalidArgument( + "the result is not equal correct result.")); } catch (paddle::platform::EnforceNotMet& error) { caught_exception = true; std::string ex_msg = error.what(); diff --git a/tools/check_api_approvals.sh b/tools/check_api_approvals.sh index fd97c17b63..63c54c8224 100644 --- a/tools/check_api_approvals.sh +++ b/tools/check_api_approvals.sh @@ -165,13 +165,13 @@ if [ "${HAS_MODIFIED_DEMO_CMAKE}" != "" ] && [ "${GIT_PR_ID}" != "" ]; then check_approval 1 328693 6836917 fi -ALL_PADDLE_ENFORCE=`git diff -U0 upstream/$BRANCH |grep "+" |grep -zoE "PADDLE_ENFORCE\(.[^,\);]+.[^;]*\);\s" || true` +ALL_PADDLE_ENFORCE=`git diff -U0 upstream/$BRANCH |grep "^+" |grep -zoE "PADDLE_ENFORCE\(.[^,\);]+.[^;]*\);\s" || true` if [ "${ALL_PADDLE_ENFORCE}" != "" ] && [ "${GIT_PR_ID}" != "" ]; then echo_line="PADDLE_ENFORCE is not recommended. Please use PADDLE_ENFORCE_EQ/NE/GT/GE/LT/LE or PADDLE_ENFORCE_NOT_NULL or PADDLE_ENFORCE_CUDA_SUCCESS instead, see [ https://github.com/PaddlePaddle/Paddle/wiki/PADDLE_ENFORCE-Rewriting-Specification ] for details.\nYou must have one RD (chenwhql (Recommend) , luotao1 (Recommend) or lanxianghit) approval for the usage (either add or delete) of PADDLE_ENFORCE.\n${ALL_PADDLE_ENFORCE}\n" check_approval 1 6836917 47554610 22561442 fi -ALL_PADDLE_CHECK=`git diff -U0 upstream/$BRANCH |grep "+" |grep -zoE "(PADDLE_ENFORCE[A-Z_]*|PADDLE_THROW)\(.[^,\);]*.[^;]*\);\s" || true` +ALL_PADDLE_CHECK=`git diff -U0 upstream/$BRANCH |grep "^+" |grep -zoE "(PADDLE_ENFORCE[A-Z_]*|PADDLE_THROW)\(.[^,\);]*.[^;]*\);\s" || true` VALID_PADDLE_CHECK=`echo "$ALL_PADDLE_CHECK" | grep -zoE '(PADDLE_ENFORCE[A-Z_]*|PADDLE_THROW)\((.[^,;]+,)*.[^";]*(errors::).[^"]*".[^";]{20,}.[^;]*\);\s' || true` INVALID_PADDLE_CHECK=`echo "$ALL_PADDLE_CHECK" |grep -vxF "$VALID_PADDLE_CHECK" || true` if [ "${INVALID_PADDLE_CHECK}" != "" ] && [ "${GIT_PR_ID}" != "" ]; then -- GitLab