run_plugin_tests.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. # Don't run this script standalone. Instead, run from the repository root:
  16. # ./tools/run_tests/run_tests.py -l objc
  17. set -ev
  18. cd $(dirname $0)
  19. # Run the tests server.
  20. BINDIR=../../../bins/$CONFIG
  21. PROTOC=$BINDIR/protobuf/protoc
  22. PLUGIN=$BINDIR/grpc_objective_c_plugin
  23. rm -rf PluginTest/*pb*
  24. $PROTOC \
  25. --plugin=protoc-gen-grpc=$PLUGIN \
  26. --objc_out=PluginTest \
  27. --grpc_out=PluginTest \
  28. -I PluginTest \
  29. -I ../../../third_party/protobuf/src \
  30. PluginTest/*.proto
  31. # Verify the output proto filename
  32. [ -e ./PluginTest/TestDashFilename.pbrpc.h ] || {
  33. echo >&2 "protoc outputs wrong filename."
  34. exit 1
  35. }
  36. # TODO(jtattermusch): rewrite the tests to make them more readable.
  37. # Also, the way they are written, they need one extra command to run in order to
  38. # clear $? after they run (see end of this script)
  39. # Verify names of the imported protos in generated code don't contain dashes.
  40. [ "`cat PluginTest/TestDashFilename.pbrpc.h |
  41. egrep '#import ".*\.pb(objc|rpc)\.h"$' |
  42. egrep '-'`" ] && {
  43. echo >&2 "protoc generated import with wrong filename."
  44. exit 1
  45. }
  46. [ "`cat PluginTest/TestDashFilename.pbrpc.m |
  47. egrep '#import ".*\.pb(objc|rpc)\.h"$' |
  48. egrep '-'`" ] && {
  49. echo >&2 "protoc generated import with wrong filename."
  50. exit 1
  51. }
  52. # Run one extra command to clear $? before exiting the script to prevent
  53. # failing even when tests pass.
  54. echo "Plugin tests passed."