Makefile 758 B

12345678910111213141516171819202122232425262728293031
  1. DIRS := \
  2. . \
  3. nl
  4. DEPS = \
  5. github.com/vishvananda/netns \
  6. golang.org/x/sys/unix
  7. uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
  8. testdirs = $(call uniq,$(foreach d,$(1),$(dir $(wildcard $(d)/*_test.go))))
  9. goroot = $(addprefix ../../../,$(1))
  10. unroot = $(subst ../../../,,$(1))
  11. fmt = $(addprefix fmt-,$(1))
  12. all: test
  13. $(call goroot,$(DEPS)):
  14. go get $(call unroot,$@)
  15. .PHONY: $(call testdirs,$(DIRS))
  16. $(call testdirs,$(DIRS)):
  17. go test -test.exec sudo -test.parallel 4 -timeout 60s -test.v github.com/vishvananda/netlink/$@
  18. $(call fmt,$(call testdirs,$(DIRS))):
  19. ! gofmt -l $(subst fmt-,,$@)/*.go | grep -q .
  20. .PHONY: fmt
  21. fmt: $(call fmt,$(call testdirs,$(DIRS)))
  22. test: fmt $(call goroot,$(DEPS)) $(call testdirs,$(DIRS))