From 7db0051660d6d51a8fd9f6ede62a8e63db0ecc2f Mon Sep 17 00:00:00 2001 From: Easwar Swaminathan Date: Thu, 12 Mar 2020 16:48:24 -0700 Subject: [PATCH] Review comments #1. --- vet.sh | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/vet.sh b/vet.sh index 1ba9d06ee77b..58d6c5af4827 100755 --- a/vet.sh +++ b/vet.sh @@ -3,9 +3,8 @@ set -ex # Exit on error; debugging enabled. set -o pipefail # Fail a pipe if any sub-command fails. -# negate_and_run makes sure that no output is seen when executing the command -# passed to it as args. -negate_and_run() { +# not makes sure the command passed to it does not exit with a return code of 0. +not() { # This is required instead of the earlier (! $COMMAND) because subshells and # pipefail don't work the same on Darwin as in Linux. ! eval "$*" @@ -17,7 +16,7 @@ die() { } fail_on_output() { - tee /dev/stderr | negate_and_run read + tee /dev/stderr | not read } # Check to make sure it's safe to modify the user's git repo. @@ -73,21 +72,21 @@ elif [[ "$#" -ne 0 ]]; then fi # - Ensure all source files contain a copyright message. -negate_and_run 'git grep -L "\(Copyright [0-9]\{4,\} gRPC authors\)\|DO NOT EDIT" -- *.go' +not 'git grep -L "\(Copyright [0-9]\{4,\} gRPC authors\)\|DO NOT EDIT" -- *.go' # - Make sure all tests in grpc and grpc/test use leakcheck via Teardown. -negate_and_run 'grep "func Test[^(]" *_test.go' -negate_and_run 'grep "func Test[^(]" test/*.go' +not 'grep "func Test[^(]" *_test.go' +not 'grep "func Test[^(]" test/*.go' # - Do not import x/net/context. -negate_and_run 'git grep -l "x/net/context" -- *.go' +not 'git grep -l "x/net/context" -- *.go' # - Do not import math/rand for real library code. Use internal/grpcrand for # thread safety. -git grep -l '"math/rand"' -- "*.go" 2>&1 | negate_and_run 'grep -v "^examples\|^stress\|grpcrand\|^benchmark\|wrr_test"' +git grep -l '"math/rand"' -- "*.go" 2>&1 | not 'grep -v "^examples\|^stress\|grpcrand\|^benchmark\|wrr_test"' # - Ensure all ptypes proto packages are renamed when importing. -negate_and_run 'git grep "\(import \|^\s*\)\"github.com/golang/protobuf/ptypes/" -- "*.go"' +not 'git grep "\(import \|^\s*\)\"github.com/golang/protobuf/ptypes/" -- "*.go"' # - Check imports that are illegal in appengine (until Go 1.11). # TODO: Remove when we drop Go 1.10 support