diff --git a/Makefile b/Makefile index dbcbd309ad..65164f7368 100644 --- a/Makefile +++ b/Makefile @@ -45,6 +45,9 @@ ALL_ARCH = amd64 arm arm64 ppc64le s390x QEMUVERSION=v2.9.1-1 +BUSTEDVERSION=2.0.rc12 +BUSTED_ARGS = -v + IMGNAME = nginx-ingress-controller IMAGE = $(REGISTRY)/$(IMGNAME) MULTI_ARCH_IMG = $(IMAGE)-$(ARCH) @@ -155,6 +158,18 @@ verify-all: test: @go test -v -race -tags "$(BUILDTAGS) cgo" $(shell go list ${PKG}/... | grep -v vendor | grep -v '/test/e2e') +.PHONY: lua-test +lua-test: + @if luarocks list --porcelain busted $(BUSTEDVERSION) | grep -q "installed" ; then \ + echo busted already installed, skipping ; \ + else \ + echo busted not found, installing via luarocks... ; \ + luarocks install busted $(BUSTEDVERSION) ; \ + fi + @for file in ./rootfs/etc/nginx/lua/test/*.lua; do \ + busted $(BUSTED_ARGS) $$file ; \ + done + .PHONY: e2e-image e2e-image: sub-container-amd64 TAG=$(TAG) IMAGE=$(MULTI_ARCH_IMG) docker tag $(IMAGE):$(TAG) $(IMAGE):test diff --git a/docs/development.md b/docs/development.md index 4cc91f6c0b..df1cbb6004 100644 --- a/docs/development.md +++ b/docs/development.md @@ -99,6 +99,17 @@ $ cd $GOPATH/src/k8s.io/ingress-nginx $ make e2e-test ``` +To run unit-tests for lua code, run: + +```console +$ cd $GOPATH/src/k8s.io/ingress-nginx +$ make lua-test +``` + +Lua tests are located in `$GOPATH/src/k8s.io/ingress-nginx/rootfs/etc/nginx/lua/test`. + + + ## Releasing All Makefiles will produce a release binary, as shown above. To publish this