Fix broken test invokation in Makefile

The Makefile did call the test suite in a broken way. It always reported
passed tests, since the exit code was always 0.
This commit is contained in:
Stefan Tatschner 2019-06-30 22:12:47 +02:00
parent fe7e103387
commit e06b832911

View file

@ -1,62 +1,43 @@
TARGET=bettercap TARGET ?= bettercap
PACKAGES=core firewall log modules network packets session tls PACKAGES ?= core firewall log modules network packets session tls
PREFIX ?= /usr/local
GO ?= go
GOFLAGS ?=
all: deps build all: build
deps: godep golint gofmt gomegacheck
@dep ensure
build_with_race_detector: resources
@go build -race -o $(TARGET) .
build: resources build: resources
@go build -o $(TARGET) . $(GO) $(GOFLAGS) build -o $(TARGET) .
build_with_race_detector: resources
$(GO) $(GOFLAGS) build -race -o $(TARGET) .
resources: network/manuf.go resources: network/manuf.go
network/manuf.go: network/manuf.go:
@python ./network/make_manuf.py @python3 ./network/make_manuf.py
clean:
@rm -rf $(TARGET)
@rm -rf build
install: install:
@mkdir -p /usr/local/share/bettercap/caplets @mkdir -p $(PREFIX)/share/bettercap/caplets
@cp bettercap /usr/local/bin/ @cp bettercap $(PREFIX)/bin/
docker: docker:
@docker build -t bettercap:latest . @docker build -t bettercap:latest .
# Go 1.9 doesn't support test coverage on multiple packages, while test:
# Go 1.10 does, let's keep it 1.9 compatible in order not to break $(GO) $(GOFLAGS) test -covermode=atomic -coverprofile=cover.out ./...
# travis
test: deps
@echo "mode: atomic" > coverage.profile
@for pkg in $(PACKAGES); do \
go fmt ./$$pkg ; \
go vet ./$$pkg ; \
megacheck ./$$pkg ; \
touch $$pkg.profile ; \
go test -race ./$$pkg -coverprofile=$$pkg.profile -covermode=atomic; \
tail -n +2 $$pkg.profile >> coverage.profile && rm -rf $$pkg.profile ; \
done
html_coverage: test html_coverage: test
@go tool cover -html=coverage.profile -o coverage.profile.html $(GO) $(GOFLAGS) tool cover -html=cover.out -o cover.out.html
benchmark: server_deps benchmark: server_deps
@go test ./... -v -run=doNotRunTests -bench=. -benchmem $(GO) $(GOFLAGS) test -v -run=doNotRunTests -bench=. -benchmem ./...
# tools fmt:
godep: $(GO) fmt -s -w $(PACKAGES)
@go get -u github.com/golang/dep/...
golint: clean:
@go get -u golang.org/x/lint/golint $(RM) $(TARGET)
$(RM) -r build
gomegacheck: .PHONY: all build build_with_race_detector resources install docker test html_coverage benchmark fmt clean
@go get honnef.co/go/tools/cmd/megacheck
gofmt:
gofmt -s -w $(PACKAGES)