elvish/Makefile
Kurtis Rader ad558b1e0d Include cross-package invocations in test coverage
The default behavior of `go test -cover` ignores coverage by integration
tests. That is, it ignores coverage by tests in a different package. This
penalizes Elvish since Elvish has a lot of integration tests that are
meant to indirectly, but explicitly, exercise code in other packages that
do not have explicit unit tests.

This change makes the test coverage more accurate for the purposes of
this project.

Resolves #1062
Resolves #1187
2021-01-03 02:05:44 +00:00

49 lines
1.4 KiB
Makefile

default: test get
get:
go get -trimpath -ldflags \
"-X github.com/elves/elvish/pkg/buildinfo.Version=$$(git describe --tags --always --dirty=-dirty) \
-X github.com/elves/elvish/pkg/buildinfo.Reproducible=true" .
# Used by elves/up
buildall:
./tools/buildall.sh
generate:
go generate ./...
# Run unit tests -- with race detection if the platform supports it. Go's
# Windows port supports race detection, but requires GCC, so we don't enable it
# there.
test:
if echo `go env GOOS GOARCH` | egrep -qx '(linux|freebsd|darwin) amd64'; then \
go test -race ./... ; \
else \
go test ./... ; \
fi
# Generate a basic test coverage report. This will open the report in your
# browser. See also https://codecov.io/gh/elves/elvish/.
cover:
go test -coverprofile=cover -coverpkg=./pkg/... ./pkg/...
go tool cover -html=cover
go tool cover -func=cover | tail -1 | awk '{ print "Overall coverage:", $$NF }'
# Ensure the style of Go and Markdown source files is consistent.
style:
find . -name '*.go' | xargs goimports -w
find . -name '*.md' | xargs prettier --tab-width 4 --prose-wrap always --write
# Check if the style of the Go and Markdown files is correct without modifying
# those files.
checkstyle: checkstyle-go checkstyle-md
checkstyle-go:
./tools/checkstyle-go.sh
checkstyle-md:
./tools/checkstyle-md.sh
.SILENT: checkstyle-go checkstyle-md
.PHONY: default get generate test style checkstyle checkstyle-go checkstyle-md cover