英文:
How to understand this Go makefile?
问题
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
我不理解这个 Golang 的 Makefile。有没有关于 Golang Makefile 的教程?我在谷歌上搜索了,但没有找到完整的教程。例如,我没有看到任何关于 "cover" 的解释等等。
英文:
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.
答案1
得分: 4
这只是一个简单的make文件,而且写得不够好。
- 运行
make
将执行test
下的命令。 make dependencies
将下载当前包的所有依赖项。make cover
将进行覆盖率测试并输出一个HTML文件。
英文:
That is just a plain make file and not even well written.
- running just
make
will execute the commands undertest
make dependencies
will download all the dependencies of the current packagesmake cover
will do coverage testing and output an html file
答案2
得分: 1
你可以在golang页面上找到足够的信息和文档。右上角有一个“搜索”功能,输入“cover”或“-cover”可以得到非常有用的信息,比如这个链接:
Cover是一个用于分析由“go test -coverprofile=cover.out”生成的覆盖率文件的程序。
Cover也被“go test -cover”用于重写源代码并添加注释,以跟踪每个函数的执行部分。它一次处理一个Go源文件,通过研究源代码来计算近似的基本块信息。因此,它比二进制重写覆盖工具更具可移植性,但功能稍微有所限制。例如,它不会探测“&&”和“||”表达式的内部,并且对于包含多个函数字面量的单个语句可能会有些困惑。有关使用信息,请参阅:
go help testflag go tool cover -help
英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论