I'm running go test ./...
in the root of my project but several packages don't have any tests and report [no test files]
. If I run 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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.