[英]How to suppress [no test files] message on go test
I'm running go test ./...
in the root of my project but several packages don't have any tests and report [no test files]
. 我正在我的项目的根目录中运行
go test ./...
但是有几个包没有任何测试和报告[no test files]
。 If I run go test ./... | grep -v 'no test files'
如果我
go test ./... | grep -v 'no test files'
go test ./... | grep -v 'no test files'
I lose the return code from go test
in case a test fails. go test ./... | grep -v 'no test files'
如果测试失败,我将失去go test
的返回码。
Can I ignore packages with no tests while recursively testing everything from the root of the project? 我可以在从项目的根目录递归测试所有内容时忽略没有测试的包吗?
Something like this? 像这样的东西?
mkfifo /tmp/fifo-$$
grep -v 'no test files' </tmp/fifo-$$ & go test ./... >/tmp/fifo-$$
RES=$?
rm /tmp/fifo-$$
exit $RES
A relatively compact solution could look like this: 一个相对紧凑的解决方案可能如下所示:
set -o pipefail
go test ./... | { grep -v 'no test files'; true; }
# reset pipefail with set +o pipefail if you want to swith it off again
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.