build: fix build

Make the "check" target as a single shell block, and 1) improve the
fail output display (by showing the left over files) and 2) ignore
the /tmp directory itself (avoiding to consider it as a left over
when some process has touched /tmp for example).

Signed-off-by: Leandro Dorileo <leandro.maciel.dorileo@intel.com>
This commit is contained in:
Leandro Dorileo
2018-10-16 14:16:46 -07:00
committed by Leandro Dorileo
parent f1b632ad64
commit b65ac90313
+13 -4
View File
@@ -82,12 +82,21 @@ check-coverage: build-local-travis
check: gopath
@# Ensure no temp files are left behind
@$(eval BEFORESHA = $(shell ls -art /tmp | sha512sum))
go test -cover ${GO_PACKAGE_PREFIX}/...
@if [ "$(BEFORESHA)" != "$$(ls -art /tmp | sha512sum)" ] ; then \
@LSCMD='ls -lart --ignore="." /tmp'; \
SHACMD='ls -art --ignore="." /tmp | sha512sum'; \
BEFORELS=`eval $$LSCMD`; \
BEFORESHA=`eval $$SHACMD`; \
go test -cover ${GO_PACKAGE_PREFIX}/...; \
AFTERSHA=`eval $$SHACMD`; \
AFTERLS=`eval $$LSCMD`; \
if [ "$$BEFORESHA" != "$$AFTERSHA" ] ; then \
echo "Test Failed: Temporary directory may not be clean!"; \
echo "Left-over files:"; \
echo "$$BEFORELS" > /tmp/beforels; \
echo "$$AFTERLS" > /tmp/afterls; \
diff -Nr /tmp/beforels /tmp/afterls; \
/bin/false ; \
fi \
fi; \
check-clean: gopath
go clean -testcache