How to exclude or skip specific directory while running 'go test' [duplicate]

℡╲_俬逩灬. 提交于 2020-07-22 21:36:31

问题


go test $(go list ./... | grep -v /vendor/) -coverprofile .testCoverage.txt

I am using the above command to test the files but there is 1 folder with the name "Store" that I want to exclude from tests. How it can be done?


回答1:


You're already doing it:

$(go list ./... | grep -v /vendor/)

The grep -v /vendor/ part is to exclude the /vendor/ directory. So just do the same for your Store directory:

go test $(go list ./... | grep -v /Store/) -coverprofile .testCoverage.txt

Note that excluding /vendor/ this way is not necessary (unless you're using a really old version of Go). If you are using an old version of Go, you can combine them:

go test $(go list ./... | grep -v /vendor/ | grep -v /Store/) -coverprofile .testCoverage.txt


来源:https://stackoverflow.com/questions/55224561/how-to-exclude-or-skip-specific-directory-while-running-go-test

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!