Skip to content

Commit 20d637a

Browse files
authored
Enforce tests do not change files in source tree (#9625)
1 parent 6a5e8d0 commit 20d637a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

.drone.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ steps:
118118
pull: always
119119
image: golang:1.13
120120
commands:
121-
- make unit-test-coverage
121+
- make unit-test-coverage test-check
122122
environment:
123123
GOPROXY: off
124124
TAGS: bindata sqlite sqlite_unlock_notify

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,18 @@ fmt-check:
226226
test:
227227
GO111MODULE=on $(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' $(PACKAGES)
228228

229+
PHONY: test-check
230+
test-check:
231+
@echo "Checking if tests have changed the source tree...";
232+
@diff=$$(git status -s); \
233+
if [ -n "$$diff" ]; then \
234+
echo "make test has changed files in the source tree:"; \
235+
echo "$${diff}"; \
236+
echo "You should change the tests to create these files in a temporary directory."; \
237+
echo "Do not simply add these files to .gitignore"; \
238+
exit 1; \
239+
fi;
240+
229241
.PHONY: test\#%
230242
test\#%:
231243
GO111MODULE=on $(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' -run $* $(PACKAGES)

0 commit comments

Comments
 (0)