| 1 |
GOTEST_PKGS=$(shell go list ./... | grep -v examples) |
| 2 |
|
| 3 |
BENCHTIME ?= 2s |
| 4 |
BENCHTESTS ?= . |
| 5 |
|
| 6 |
BENCHFULL?=0 |
| 7 |
ifeq (${BENCHFULL},1) |
| 8 |
BENCHFULL_ARG=-bench-full -timeout 60m |
| 9 |
else |
| 10 |
BENCHFULL_ARG= |
| 11 |
endif |
| 12 |
|
| 13 |
TEST_VERBOSE?=0 |
| 14 |
ifeq (${TEST_VERBOSE},1) |
| 15 |
TEST_VERBOSE_ARG=-v |
| 16 |
else |
| 17 |
TEST_VERBOSE_ARG= |
| 18 |
endif |
| 19 |
|
| 20 |
TEST_RESULTS?="/tmp/test-results" |
| 21 |
grammar.go: grammar.peg |
| 22 |
@echo "Regenerating Parser" |
| 23 |
@go generate ./ |
| 24 |
|
| 25 |
generate: grammar.go |
| 26 |
|
| 27 |
test: generate |
| 28 |
@go test $(TEST_VERBOSE_ARG) $(GOTEST_PKGS) |
| 29 |
|
| 30 |
test-ci: generate |
| 31 |
@gotestsum --junitfile $(TEST_RESULTS)/gotestsum-report.xml -- $(GOTEST_PKGS) |
| 32 |
|
| 33 |
bench: generate |
| 34 |
@go test $(TEST_VERBOSE_ARG) -run DONTRUNTESTS -bench $(BENCHTESTS) $(BENCHFULL_ARG) -benchtime=$(BENCHTIME) $(GOTEST_PKGS) |
| 35 |
|
| 36 |
coverage: generate |
| 37 |
@go test -coverprofile /tmp/coverage.out $(GOTEST_PKGS) |
| 38 |
@go tool cover -html /tmp/coverage.out |
| 39 |
|
| 40 |
fmt: generate |
| 41 |
@gofmt -w -s |
| 42 |
|
| 43 |
examples: simple expr-parse expr-eval filter |
| 44 |
|
| 45 |
simple: |
| 46 |
@go build ./examples/simple |
| 47 |
|
| 48 |
expr-parse: |
| 49 |
@go build ./examples/expr-parse |
| 50 |
|
| 51 |
expr-eval: |
| 52 |
@go build ./examples/expr-eval |
| 53 |
|
| 54 |
filter: |
| 55 |
@go build ./examples/filter |
| 56 |
|
| 57 |
deps: |
| 58 |
@go get github.com/mna/pigeon@master |
| 59 |
@go get golang.org/x/tools/cmd/goimports |
| 60 |
@go get golang.org/x/tools/cmd/cover |
| 61 |
@go mod tidy |
| 62 |
|
| 63 |
.PHONY: generate test coverage fmt deps bench examples expr-parse expr-eval filter |
| 64 |
|