From 20d637a0f834a4ed50dd87bce496be5e1604986b Mon Sep 17 00:00:00 2001 From: zeripath Date: Sun, 26 Jan 2020 20:07:12 +0000 Subject: [PATCH] Enforce tests do not change files in source tree (#9625) --- .drone.yml | 2 +- Makefile | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 12017fc51fc8..716e7b1d59d6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -118,7 +118,7 @@ steps: pull: always image: golang:1.13 commands: - - make unit-test-coverage + - make unit-test-coverage test-check environment: GOPROXY: off TAGS: bindata sqlite sqlite_unlock_notify diff --git a/Makefile b/Makefile index 7f79e5de9e93..f5d0fb7f777d 100644 --- a/Makefile +++ b/Makefile @@ -226,6 +226,18 @@ fmt-check: test: GO111MODULE=on $(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' $(PACKAGES) +PHONY: test-check +test-check: + @echo "Checking if tests have changed the source tree..."; + @diff=$$(git status -s); \ + if [ -n "$$diff" ]; then \ + echo "make test has changed files in the source tree:"; \ + echo "$${diff}"; \ + echo "You should change the tests to create these files in a temporary directory."; \ + echo "Do not simply add these files to .gitignore"; \ + exit 1; \ + fi; + .PHONY: test\#% test\#%: GO111MODULE=on $(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' -run $* $(PACKAGES)