Skip to content

Commit

Permalink
hack: update verify-code-patterns.sh (#221)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ahmetb authored Jun 27, 2019
1 parent bca4cde commit 4e47fbc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hack/verify-code-patterns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 4e47fbc

Please sign in to comment.