Jan Tattermusch | 9359e50 | 2017-08-02 10:10:52 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright 2015 gRPC authors. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | # Don't run this script standalone. Instead, run from the repository root: |
| 17 | # ./tools/run_tests/run_tests.py -l objc |
| 18 | |
| 19 | set -ev |
| 20 | |
| 21 | cd $(dirname $0) |
| 22 | |
| 23 | # Run the tests server. |
| 24 | |
| 25 | BINDIR=../../../bins/$CONFIG |
| 26 | PROTOC=$BINDIR/protobuf/protoc |
| 27 | PLUGIN=$BINDIR/grpc_objective_c_plugin |
| 28 | |
| 29 | rm -rf PluginTest/*pb* |
| 30 | |
| 31 | $PROTOC \ |
| 32 | --plugin=protoc-gen-grpc=$PLUGIN \ |
| 33 | --objc_out=PluginTest \ |
| 34 | --grpc_out=PluginTest \ |
| 35 | -I PluginTest \ |
| 36 | -I ../../../third_party/protobuf/src \ |
| 37 | PluginTest/*.proto |
| 38 | |
| 39 | # Verify the output proto filename |
| 40 | [ -e ./PluginTest/TestDashFilename.pbrpc.h ] || { |
| 41 | echo >&2 "protoc outputs wrong filename." |
| 42 | exit 1 |
| 43 | } |
| 44 | |
Jan Tattermusch | 26cdf5b | 2017-08-10 10:03:56 +0200 | [diff] [blame] | 45 | # TODO(jtattermusch): rewrite the tests to make them more readable. |
| 46 | # Also, the way they are written, they need one extra command to run in order to |
| 47 | # clear $? after they run (see end of this script) |
| 48 | # Verify names of the imported protos in generated code don't contain dashes. |
Jan Tattermusch | 9359e50 | 2017-08-02 10:10:52 +0200 | [diff] [blame] | 49 | [ "`cat PluginTest/TestDashFilename.pbrpc.h | |
| 50 | egrep '#import ".*\.pb(objc|rpc)\.h"$' | |
| 51 | egrep '-'`" ] && { |
| 52 | echo >&2 "protoc generated import with wrong filename." |
| 53 | exit 1 |
| 54 | } |
| 55 | [ "`cat PluginTest/TestDashFilename.pbrpc.m | |
Jan Tattermusch | 26cdf5b | 2017-08-10 10:03:56 +0200 | [diff] [blame] | 56 | egrep '#import ".*\.pb(objc|rpc)\.h"$' | |
Jan Tattermusch | 9359e50 | 2017-08-02 10:10:52 +0200 | [diff] [blame] | 57 | egrep '-'`" ] && { |
| 58 | echo >&2 "protoc generated import with wrong filename." |
| 59 | exit 1 |
| 60 | } |
Jan Tattermusch | 26cdf5b | 2017-08-10 10:03:56 +0200 | [diff] [blame] | 61 | |
| 62 | # Run one extra command to clear $? before exiting the script to prevent |
| 63 | # failing even when tests pass. |
| 64 | echo "Plugin tests passed." |