Skip to content

Instantly share code, notes, and snippets.

@advancedwebdeveloper
Created October 12, 2020 11:02
Show Gist options
  • Save advancedwebdeveloper/ff0ac3e41c2a4667f8a2e9f18ce2fd9f to your computer and use it in GitHub Desktop.
Save advancedwebdeveloper/ff0ac3e41c2a4667f8a2e9f18ce2fd9f to your computer and use it in GitHub Desktop.
DIRS := \
. \
nl
DEPS = \
github.com/vishvananda/netns \
golang.org/x/sys/unix
uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
testdirs = $(call uniq,$(foreach d,$(1),$(dir $(wildcard $(d)/*_test.go))))
goroot = $(addprefix ../../../,$(1))
unroot = $(subst ../../../,,$(1))
fmt = $(addprefix fmt-,$(1))
all: test
$(call goroot,$(DEPS)):
go get $(call unroot,$@)
.PHONY: $(call testdirs,$(DIRS))
$(call testdirs,$(DIRS)):
sudo go test -parallel 4 -timeout 60s -test.v github.com/vishvananda/netlink/$@
$(call fmt,$(call testdirs,$(DIRS))):
! gofmt -l $(subst fmt-,,$@)/*.go | grep -q .
.PHONY: fmt
fmt: $(call fmt,$(call testdirs,$(DIRS)))
test: fmt $(call goroot,$(DEPS)) $(call testdirs,$(DIRS))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment