Reputation: 8103
COVERPROFILE=cover.out
default: test
cover:
go test -coverprofile=$(COVERPROFILE) .
go tool cover -html=$(COVERPROFILE)
rm $(COVERPROFILE)
dependencies:
go get -d .
test:
go test -i ./...
go test -v ./...
.PHONY: coverage dependencies test
I don't understand this golang makefile. Is there any tutorial for golang makefiles? I searched Google and didn't find any complete one. For example, I don't see any explanation for what is "cover," etc.
Upvotes: 1
Views: 1373
Reputation: 5697
You can find enough info and documentation on golang page. There is a "search" in upper right corner, inserting "cover" or "-cover" yielded very useful info, such as this:
Cover is a program for analyzing the coverage profiles generated by 'go test -coverprofile=cover.out'. Cover is also used by 'go test -cover' to rewrite the source code with annotations to track which parts of each function are executed. It operates on one Go source file at a time, computing approximate basic block information by studying the source. It is thus more portable than binary-rewriting coverage tools, but also a little less capable. For instance, it does not probe inside && and || expressions, and can be mildly confused by single statements with multiple function literals.
For usage information, please see:
go help testflag
go tool cover -help
Upvotes: 1
Reputation: 48310
That is just a plain make file and not even well written.
make
will execute the commands under test
make dependencies
will download all the dependencies of the current packagesmake cover
will do coverage testing and output an html file Upvotes: 4