• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
19set -ev
20
21cd $(dirname $0)
22
23# Run the tests server.
24
25BINDIR=../../../bins/$CONFIG
26PROTOC=$BINDIR/protobuf/protoc
27PLUGIN=$BINDIR/grpc_objective_c_plugin
28
29rm -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
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.
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 |
56    egrep '#import ".*\.pb(objc|rpc)\.h"$' |
57    egrep '-'`" ] && {
58    echo >&2 "protoc generated import with wrong filename."
59    exit 1
60}
61
62# Run one extra command to clear $? before exiting the script to prevent
63# failing even when tests pass.
64echo "Plugin tests passed."
65