improved makefile with tests, benchmarks n stuff

This commit is contained in:
evilsocket 2018-04-24 14:33:53 +02:00
commit 64099bc1fb
No known key found for this signature in database
GPG key ID: 1564D7F30393A456

View file

@ -1,13 +1,12 @@
TARGET=bettercap
PACKAGES=core firewall log modules network packets session tls
all: fmt vet build
@echo "@ Done"
all: deps build
test: build
@go test ./...
deps: godep golint gomegacheck
@dep ensure
build: resources
@echo "@ Building ..."
@go build -o $(TARGET) .
resources: network/oui.go
@ -15,19 +14,42 @@ resources: network/oui.go
network/oui.go:
@python ./network/make_oui.py
vet:
@go vet ./...
fmt:
@go fmt ./...
lint:
@golint ./...
deps:
@dep ensure
clean:
@rm -rf $(TARGET).*
@rm -rf $(TARGET)*
@rm -rf build
docker:
@docker build -t bettercap:latest .
# Go 1.9 doesn't support test coverage on multiple packages, while
# Go 1.10 does, let's keep it 1.9 compatible in order not to break
# travis
test: deps
@echo "mode: atomic" > coverage.profile
@for pkg in $(PACKAGES); do \
go fmt ./$$pkg ; \
go vet ./$$pkg ; \
megacheck ./$$pkg ; \
go test -race ./$$pkg -coverprofile=$$pkg.profile -covermode=atomic; \
tail -n +2 $$pkg.profile >> coverage.profile && rm $$pkg.profile ; \
done
html_coverage: test
@go tool cover -html=coverage.profile -o coverage.profile.html
codecov: test
@bash <(curl -s https://codecov.io/bash)
benchmark: server_deps
@go test ./... -v -run=doNotRunTests -bench=. -benchmem
# tools
godep:
@go get -u github.com/golang/dep/...
golint:
@go get github.com/golang/lint/golint
gomegacheck:
@go get honnef.co/go/tools/cmd/megacheck