From 7352bae1bb02d0d66091f85761934e7fcc1b95ef Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 8 Jun 2017 09:58:06 -0700 Subject: [PATCH] Move tests --- .../tests/PluginTest/imported-with-dash.proto | 38 +++++++++++++++++++ .../test-dash-filename.proto | 8 +++- src/objective-c/tests/build_tests.sh | 22 ----------- src/objective-c/tests/run_tests.sh | 32 ++++++++++++++++ 4 files changed, 77 insertions(+), 23 deletions(-) create mode 100644 src/objective-c/tests/PluginTest/imported-with-dash.proto rename src/objective-c/tests/{RemoteTestClient => PluginTest}/test-dash-filename.proto (94%) diff --git a/src/objective-c/tests/PluginTest/imported-with-dash.proto b/src/objective-c/tests/PluginTest/imported-with-dash.proto new file mode 100644 index 00000000000..0c4ee3827ad --- /dev/null +++ b/src/objective-c/tests/PluginTest/imported-with-dash.proto @@ -0,0 +1,38 @@ +// Copyright 2017, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package grpc.testing; + +option objc_class_prefix = "RMT"; + +message TestMessageImported { + int32 dummy = 1; +} diff --git a/src/objective-c/tests/RemoteTestClient/test-dash-filename.proto b/src/objective-c/tests/PluginTest/test-dash-filename.proto similarity index 94% rename from src/objective-c/tests/RemoteTestClient/test-dash-filename.proto rename to src/objective-c/tests/PluginTest/test-dash-filename.proto index 413d6f9eaac..be9386f9608 100644 --- a/src/objective-c/tests/RemoteTestClient/test-dash-filename.proto +++ b/src/objective-c/tests/PluginTest/test-dash-filename.proto @@ -1,4 +1,4 @@ -// Copyright 2015, Google Inc. +// Copyright 2017, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -35,5 +35,11 @@ package grpc.testing; option objc_class_prefix = "RMT"; +import "imported-with-dash.proto"; + +message TestMessage { + int32 dummy = 1; +} + service DummyService { } diff --git a/src/objective-c/tests/build_tests.sh b/src/objective-c/tests/build_tests.sh index 496dbcbe600..4b3ed21886c 100755 --- a/src/objective-c/tests/build_tests.sh +++ b/src/objective-c/tests/build_tests.sh @@ -53,25 +53,3 @@ rm -f RemoteTestClient/*.{h,m} echo "TIME: $(date)" pod install -# Verify the output proto name -[ -e ./RemoteTestClient/Test-dash-filename.pbrpc.h ] || { - echo >&2 "protoc outputs wrong filename." - exit 1 -} - -# Verify the output proto name when dash is treated as separator -PROTOC=../../../bins/$CONFIG/protobuf/protoc -PLUGIN=../../../bins/$CONFIG/grpc_objective_c_plugin - -eval $PROTOC \ - --plugin=protoc-gen-grpc=$PLUGIN \ - --objc_out=RemoteTestClient \ - --grpc_out=filename-dash-as-separator:RemoteTestClient \ - -I RemoteTestClient \ - -I ../../../third_party/protobuf/src \ - RemoteTestClient/*.proto - -[ -e ./RemoteTestClient/TestDashFilename.pbrpc.h ] || { - echo >&2 "protoc outputs wring filename. 2" - exit 1 -} diff --git a/src/objective-c/tests/run_tests.sh b/src/objective-c/tests/run_tests.sh index 2432209f4f1..2d61910bbda 100755 --- a/src/objective-c/tests/run_tests.sh +++ b/src/objective-c/tests/run_tests.sh @@ -38,6 +38,38 @@ cd $(dirname $0) # Run the tests server. BINDIR=../../../bins/$CONFIG +PROTOC=$BINDIR/protobuf/protoc +PLUGIN=$BINDIR/grpc_objective_c_plugin + +rm -rf PluginTest/*pb* + +# Verify the output proto filename +eval $PROTOC \ + --plugin=protoc-gen-grpc=$PLUGIN \ + --objc_out=PluginTest \ + --grpc_out=PluginTest \ + -I PluginTest \ + -I ../../../third_party/protobuf/src \ + PluginTest/*.proto + +[ -e ./PluginTest/TestDashFilename.pbrpc.h ] || { + echo >&2 "protoc outputs wrong filename." + exit 1 +} + +# Verify names of the imported protos in generated code +[ "`cat PluginTest/TestDashFilename.pbrpc.h | + egrep '#import ".*\.pb(objc|rpc)\.h"$' | + egrep '-'`" ] && { + echo >&2 "protoc generated import with wrong filename." + exit 1 +} +[ "`cat PluginTest/TestDashFilename.pbrpc.m | + egrep '#import ".*\.pb(objc|rpc)\.m"$' | + egrep '-'`" ] && { + echo >&2 "protoc generated import with wrong filename." + exit 1 +} [ -f $BINDIR/interop_server ] || { echo >&2 "Can't find the test server. Make sure run_tests.py is making" \