mirror of
https://gitee.com/iresty/apisix.git
synced 2024-11-30 02:57:49 +08:00
test case: optimize output of check-plugins-code (#2173)
This commit is contained in:
parent
d2f622e280
commit
3ece377d3f
@ -164,7 +164,7 @@ script() {
|
||||
./bin/apisix stop
|
||||
sleep 1
|
||||
|
||||
sudo sh ./utils/check-plugins-code.sh
|
||||
sudo bash ./utils/check-plugins-code.sh
|
||||
|
||||
make lint && make license-check || exit 1
|
||||
APISIX_ENABLE_LUACOV=1 PERL5LIB=.:$PERL5LIB prove -Itest-nginx/lib -r t
|
||||
|
@ -17,25 +17,29 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
RED="\033[1;31m";
|
||||
NC="\033[0m"; # No Color
|
||||
hit=0
|
||||
|
||||
checkfunc () {
|
||||
funccontent=$1
|
||||
[[ $funccontent =~ "core.response.exit" ]] && echo "can't exit in rewrite or access phase !" && exit 1
|
||||
[[ $funccontent =~ "ngx.exit" ]] && echo "can't exit in rewrite or access phase !" && exit 1
|
||||
echo "passed."
|
||||
file=$2
|
||||
[[ $funccontent =~ "core.response.exit" ]] && echo -e ${RED}${file}${NC} && echo " can't exit in rewrite or access phase!" && ((hit++))
|
||||
[[ $funccontent =~ "ngx.exit" ]] && echo -e ${RED}${file}${NC} && echo " can't exit in rewrite or access phase!" && ((hit++))
|
||||
}
|
||||
|
||||
|
||||
filtercode () {
|
||||
content=$1
|
||||
file=$2
|
||||
|
||||
rcontent=${content##*_M.rewrite}
|
||||
rewritefunc=${rcontent%%function*}
|
||||
checkfunc "$rewritefunc"
|
||||
checkfunc "$rewritefunc" "$file"
|
||||
|
||||
rcontent=${content##*_M.access}
|
||||
accessfunc=${rcontent%%function*}
|
||||
checkfunc "$accessfunc"
|
||||
checkfunc "$accessfunc" "$file"
|
||||
}
|
||||
|
||||
|
||||
@ -43,14 +47,18 @@ for file in apisix/plugins/*.lua
|
||||
do
|
||||
if test -f $file
|
||||
then
|
||||
echo $file
|
||||
content=$(cat $file)
|
||||
filtercode "$content"
|
||||
filtercode "$content" "$file"
|
||||
fi
|
||||
done
|
||||
|
||||
if (($hit>0))
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# test case for check
|
||||
content=$(cat t/fake-plugin-exit.lua)
|
||||
filtercode "$content" > test.log 2>&1 || (cat test.log && exit 1)
|
||||
|
||||
echo "done."
|
||||
echo "All passed."
|
||||
|
Loading…
Reference in New Issue
Block a user