src.elv.sh@v0.21.0-dev.0.20240515223629-06979efb9a2a/Makefile (about) 1 ELVISH_MAKE_BIN ?= $(or $(GOBIN),$(shell go env GOPATH)/bin)/elvish$(shell go env GOEXE) 2 ELVISH_MAKE_BIN := $(subst \,/,$(ELVISH_MAKE_BIN)) 3 ELVISH_MAKE_PKG ?= ./cmd/elvish 4 5 default: test most-checks get 6 7 # This target emulates the behavior of "go install ./cmd/elvish", except that 8 # the build output and the main package to build can be overridden with 9 # environment variables. 10 get: 11 mkdir -p $(shell dirname $(ELVISH_MAKE_BIN)) 12 go build -o $(ELVISH_MAKE_BIN) $(ELVISH_MAKE_PKG) 13 14 # Run formatters on Go and Markdown files. 15 fmt: 16 find . -name '*.go' | xargs goimports -w 17 find . -name '*.go' | xargs gofmt -s -w 18 find . -name '*.md' | xargs go run src.elv.sh/cmd/elvmdfmt -w -width 80 19 20 # Run unit tests, with race detection if the platform supports it. 21 test: 22 go test $(shell ./tools/run-race.elv) ./... 23 cd website; go test $(shell ./tools/run-race.elv) ./... 24 25 # Generate a basic test coverage report, and open it in the browser. The report 26 # is an approximation of https://app.codecov.io/gh/elves/elvish/. 27 cover: 28 go test -coverprofile=cover -coverpkg=./pkg/... ./pkg/... 29 ./tools/prune-cover.sh .codecov.yml cover 30 go tool cover -html=cover 31 go tool cover -func=cover | tail -1 | awk '{ print "Overall coverage:", $$NF }' 32 33 # All the checks except check-gen.sh, which is not always convenient to run as 34 # it requires a clean working tree. 35 most-checks: 36 ./tools/check-fmt-go.sh 37 ./tools/check-fmt-md.sh 38 ./tools/check-disallowed.sh 39 codespell 40 go vet ./... 41 staticcheck ./... 42 43 all-checks: most-checks 44 ./tools/check-gen.sh 45 46 .PHONY: default get fmt test cover most-checks all-checks