Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/protoc-gen-go-grpc: add change detector test #7072

Merged
merged 23 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ jobs:

# Run the main gRPC-Go tests.
tests:
# Proto checks are run in the above job.
env:
VET_SKIP_PROTO: 1
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
Expand Down Expand Up @@ -98,7 +95,7 @@ jobs:
# Only run vet for 'vet' runs.
- name: Run vet.sh
if: matrix.type == 'vet'
run: ./vet.sh -install && ./vet.sh
run: export VET_SKIP_PROTO=1 && ./vet.sh -install && ./vet.sh

# Main tests run for everything except when testing "extras"
# (where we run a reduced set of tests).
Expand Down Expand Up @@ -128,3 +125,6 @@ jobs:
interop/interop_test.sh
echo -e "\n-- Running xDS E2E Test --"
xds/internal/test/e2e/run.sh
echo -e "\n-- Running protoc-gen-go-grpc test --"
./vet.sh -install
cmd/protoc-gen-go-grpc/protoc-gen-go-grpc_test.sh
2 changes: 1 addition & 1 deletion cmd/protoc-gen-go-grpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ change from the grpc code generator previously included with `protoc-gen-go`.
To restore this behavior, set the option `require_unimplemented_servers=false`.
E.g.:

```
```sh
protoc --go-grpc_out=. --go-grpc_opt=require_unimplemented_servers=false[,other options...] \
```

Expand Down
34 changes: 34 additions & 0 deletions cmd/protoc-gen-go-grpc/proto/golden.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2024 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

option go_package = "testdata/proto";
arvindbr8 marked this conversation as resolved.
Show resolved Hide resolved

package main;

message EventRequest {
bytes content = 1;
}

message EventResponse {
bytes content = 1;
}

service BidirectionalStreamingService {
rpc unaryMethod(EventRequest) returns (EventResponse) {}
rpc clientMethod(stream EventRequest) returns (EventResponse) {}
rpc serverMethod(EventRequest) returns (stream EventResponse) {};
rpc bidirectionalMethod(stream EventRequest) returns (stream EventResponse) {}
}
25 changes: 25 additions & 0 deletions cmd/protoc-gen-go-grpc/protoc-gen-go-grpc_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

set -ex # Debugging enabled.

trap "git clean --force --quiet" EXIT

WD="$(dirname $0)"

# Build protoc-gen-go-grpc binary and add to $PATH.
pushd "${WD}"
go build .
PATH="${WD}:${PATH}"
popd

protoc \
--go-grpc_out=. \
arvindbr8 marked this conversation as resolved.
Show resolved Hide resolved
--go-grpc_opt=paths=source_relative \
arvindbr8 marked this conversation as resolved.
Show resolved Hide resolved
"$WD/proto/golden.proto"

if !(diff -u "${WD}/testdata/golden_grpc.pb.go" "${WD}/proto/golden_grpc.pb.go"); then
echo "Generated file golden_grpc.pb.go differs from golden file; If you have made recent changes to protoc-gen-go-grpc, please regenerate the golden files." >&2
arvindbr8 marked this conversation as resolved.
Show resolved Hide resolved
exit 1
fi

echo SUCCESS
Loading
Loading