This is an automated email from the ASF dual-hosted git repository.
spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new cdb5aaf ci: lint test file (#3298)
cdb5aaf is described below
commit cdb5aaf3d7e716109b6d9a04a4a423fe2a84e0eb
Author: 罗泽轩 <[email protected]>
AuthorDate: Sun Jan 17 20:27:28 2021 -0600
ci: lint test file (#3298)
Signed-off-by: spacewander <[email protected]>
---
.gitignore | 1 +
Makefile | 7 ++++++-
t/admin/consumers2.t | 2 --
t/admin/upstream2.t | 3 +--
t/router/graphql.t | 1 +
utils/check-lua-code-style.sh | 2 +-
utils/{check-lua-code-style.sh => check-test-code-style.sh} | 13 ++++++-------
7 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/.gitignore b/.gitignore
index 665f66d..ee5e22a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -53,6 +53,7 @@ proxy_temp
fastcgi_temp
client_body_temp
utils/lj-releng
+utils/reindex
default.etcd/
.idea/
*.iml
diff --git a/Makefile b/Makefile
index 026d540..10e54d3 100644
--- a/Makefile
+++ b/Makefile
@@ -65,12 +65,17 @@ ifeq ("$(wildcard utils/lj-releng)", "")
wget -P utils
https://raw.githubusercontent.com/iresty/openresty-devel-utils/master/lj-releng
chmod a+x utils/lj-releng
endif
+ifeq ("$(wildcard utils/reindex)", "")
+ wget -P utils
https://raw.githubusercontent.com/iresty/openresty-devel-utils/master/reindex
+ chmod a+x utils/reindex
+endif
-### lint: Lint Lua source code
+### lint: Lint source code
.PHONY: lint
lint: utils
./utils/check-lua-code-style.sh
+ ./utils/check-test-code-style.sh
### init: Initialize the runtime environment
diff --git a/t/admin/consumers2.t b/t/admin/consumers2.t
index 455b3fc..eda7671 100644
--- a/t/admin/consumers2.t
+++ b/t/admin/consumers2.t
@@ -69,7 +69,6 @@ __DATA__
-
=== TEST 2: not unwanted data, GET
--- config
location /t {
@@ -98,7 +97,6 @@ __DATA__
-
=== TEST 3: not unwanted data, DELETE
--- config
location /t {
diff --git a/t/admin/upstream2.t b/t/admin/upstream2.t
index 0526879..b753383 100644
--- a/t/admin/upstream2.t
+++ b/t/admin/upstream2.t
@@ -72,7 +72,6 @@ __DATA__
-
=== TEST 2: not unwanted data, PUT
--- config
location /t {
@@ -106,7 +105,6 @@ __DATA__
-
=== TEST 3: not unwanted data, PATCH
--- config
location /t {
@@ -248,6 +246,7 @@ passed
passed
+
=== TEST 8: hit empty nodes upstream
--- request
GET /index.html
diff --git a/t/router/graphql.t b/t/router/graphql.t
index 65edd03..618b5ac 100644
--- a/t/router/graphql.t
+++ b/t/router/graphql.t
@@ -67,6 +67,7 @@ __DATA__
passed
+
=== TEST 2: route by name
--- request
POST /hello
diff --git a/utils/check-lua-code-style.sh b/utils/check-lua-code-style.sh
index 2723256..59fe473 100755
--- a/utils/check-lua-code-style.sh
+++ b/utils/check-lua-code-style.sh
@@ -24,7 +24,7 @@ luacheck -q apisix t/lib
find apisix -name '*.lua' ! -wholename 'apisix/cli/ngx_tpl.lua' -exec
./utils/lj-releng {} + > \
/tmp/check.log 2>&1 || (cat /tmp/check.log && exit 1)
-grep -E "ERROR.*.lua:" /tmp/check.log > /tmp/error.log | true
+grep -E "ERROR.*.lua:" /tmp/check.log > /tmp/error.log || true
if [ -s /tmp/error.log ]; then
echo "=====bad style====="
cat /tmp/check.log
diff --git a/utils/check-lua-code-style.sh b/utils/check-test-code-style.sh
similarity index 78%
copy from utils/check-lua-code-style.sh
copy to utils/check-test-code-style.sh
index 2723256..b3e4f36 100755
--- a/utils/check-lua-code-style.sh
+++ b/utils/check-test-code-style.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,16 +17,15 @@
# limitations under the License.
#
-set -ex
+set -x -euo pipefail
-luacheck -q apisix t/lib
-
-find apisix -name '*.lua' ! -wholename 'apisix/cli/ngx_tpl.lua' -exec
./utils/lj-releng {} + > \
+find t -name '*.t' -exec ./utils/reindex {} + > \
/tmp/check.log 2>&1 || (cat /tmp/check.log && exit 1)
-grep -E "ERROR.*.lua:" /tmp/check.log > /tmp/error.log | true
+grep "done." /tmp/check.log > /tmp/error.log || true
if [ -s /tmp/error.log ]; then
echo "=====bad style====="
- cat /tmp/check.log
+ cat /tmp/error.log
+ echo "you need to run 'reindex' to fix them. Read CONTRIBUTING.md for more
details."
exit 1
fi