Makefile: further adjust variables for make test

When we run make test, we don't want to import settings from the user
(global) or system configuration files, since those can break things in
our tests.  Set GIT_CONFIG_NOSYSTEM to disable the system config file,
and unset XDG_CONFIG_HOME to disable one possible global config file.
Set HOME to a temporary directory, since Go wants to use it to find
cache locations.  Store the actual temporary directory in a variable
that we remove after the fact so that we can avoid deleting HOME just in
case something goes wrong.
This commit is contained in:
brian m. carlson 2020-05-13 20:51:59 +00:00
parent 0757f47cea
commit 1d4e46b311
No known key found for this signature in database
GPG Key ID: 2D0C9BC12F82B3A1

@ -409,8 +409,16 @@ test-race : GO_TEST_EXTRA_ARGS=-race
#
# And so on.
test : fmt $(.DEFAULT_GOAL)
(unset GIT_DIR; unset GIT_WORK_TREE; \
$(GO) test -count=1 $(GO_TEST_EXTRA_ARGS) $(addprefix ./,$(PKGS)))
( \
unset GIT_DIR; unset GIT_WORK_TREE; unset XDG_CONFIG_HOME; \
tempdir="$$(mktemp -d)"; \
export HOME="$$tempdir"; \
export GIT_CONFIG_NOSYSTEM=1; \
$(GO) test -count=1 $(GO_TEST_EXTRA_ARGS) $(addprefix ./,$(PKGS)); \
RET=$$?; \
rm -fr "$$tempdir"; \
exit $$RET; \
)
# integration is a shorthand for running 'make' in the 't' directory.
.PHONY : integration