From 4e47fbc4082cd720181ad304948e2914305946ad Mon Sep 17 00:00:00 2001 From: Ahmet Alp Balkan Date: Thu, 27 Jun 2019 15:41:55 -0700 Subject: [PATCH] hack: update verify-code-patterns.sh (#221) This fixes an issue where sometimes bash returns 1 instead of 123 in the exitcode of the pipe. This simplifies the find|xargs|grep with just grep. Signed-off-by: Ahmet Alp Balkan --- hack/verify-code-patterns.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hack/verify-code-patterns.sh b/hack/verify-code-patterns.sh index 1c7e4431a0..1356396739 100755 --- a/hack/verify-code-patterns.sh +++ b/hack/verify-code-patterns.sh @@ -16,7 +16,8 @@ set -euo pipefail -out="$( find . -name '*_test.go' -not -path './vendor/*' -print0 | xargs -0 grep -En 'ioutil\.TempDir' || [[ $? == 123 ]] )" +# Disallow usage of ioutil.TempDir in tests in favor of testutil. +out="$(grep --include '*_test.go' --exclude-dir 'vendor/' -EIrn 'ioutil.\TempDir' || true)" if [[ -n "$out" ]]; then echo >&2 "You used ioutil.TempDir in tests, use 'testutil.NewTempDir()' instead:" echo >&2 "$out"