Skip to content

Commit

Permalink
Review comments #1.
Browse files Browse the repository at this point in the history
  • Loading branch information
easwars committed Mar 12, 2020
1 parent 969e337 commit 7db0051
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions vet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$*"
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7db0051

Please sign in to comment.