Makefile 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. default: test get
  5. # This target emulates the behavior of "go install ./cmd/elvish", except that
  6. # the build output and the main package to build can be overridden with
  7. # environment variables.
  8. get:
  9. mkdir -p $(shell dirname $(ELVISH_MAKE_BIN))
  10. go build -o $(ELVISH_MAKE_BIN) $(ELVISH_MAKE_PKG)
  11. generate:
  12. go generate ./...
  13. # Run unit tests, with race detection if the platform supports it.
  14. test:
  15. go test $(shell ./tools/run-race.sh) ./...
  16. cd website; go test $(shell ./tools/run-race.sh) ./...
  17. # Generate a basic test coverage report, and open it in the browser. See also
  18. # https://apps.codecov.io/gh/elves/elvish/.
  19. cover:
  20. go test -coverprofile=cover -coverpkg=./pkg/... ./pkg/...
  21. ./tools/prune-cover.sh .codecov.yml cover
  22. go tool cover -html=cover
  23. go tool cover -func=cover | tail -1 | awk '{ print "Overall coverage:", $$NF }'
  24. # Ensure the style of Go and Markdown source files is consistent.
  25. style:
  26. find . -name '*.go' | xargs goimports -w
  27. find . -name '*.go' | xargs gofmt -s -w
  28. find . -name '*.md' | xargs go run src.elv.sh/cmd/elvmdfmt -w -width 80
  29. # Check if the style of the Go and Markdown files is correct without modifying
  30. # those files.
  31. checkstyle: checkstyle-go checkstyle-md
  32. checkstyle-go:
  33. ./tools/checkstyle-go.sh
  34. checkstyle-md:
  35. ./tools/checkstyle-md.sh
  36. lint:
  37. ./tools/lint.sh
  38. codespell:
  39. codespell --skip .git
  40. check-content:
  41. ./tools/check-content.sh
  42. .SILENT: checkstyle-go checkstyle-md lint
  43. .PHONY: default get generate test cover style checkstyle checkstyle-go checkstyle-md lint codespell check-content