run_plugin_tests.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. ROOT_DIR=../../..
  21. BAZEL=$ROOT_DIR/tools/bazel
  22. BAZEL_EXEC_ROOT=$ROOT_DIR/bazel-out/darwin-fastbuild/bin
  23. PROTOC=$BAZEL_EXEC_ROOT/external/com_google_protobuf/protoc
  24. PLUGIN=$BAZEL_EXEC_ROOT/src/compiler/grpc_objective_c_plugin
  25. [ -f $PROTOC ] && [ -f $PLUGIN ] || {
  26. BAZEL build @com_google_protobuf//:protoc //src/compiler:grpc_objective_c_plugin
  27. }
  28. rm -rf PluginTest/*pb*
  29. $PROTOC \
  30. --plugin=protoc-gen-grpc=$PLUGIN \
  31. --objc_out=PluginTest \
  32. --grpc_out=PluginTest \
  33. -I PluginTest \
  34. -I ../../../third_party/protobuf/src \
  35. PluginTest/*.proto
  36. # Verify the output proto filename
  37. [ -e ./PluginTest/TestDashFilename.pbrpc.h ] || {
  38. echo >&2 "protoc outputs wrong filename."
  39. exit 1
  40. }
  41. # TODO(jtattermusch): rewrite the tests to make them more readable.
  42. # Also, the way they are written, they need one extra command to run in order to
  43. # clear $? after they run (see end of this script)
  44. # Verify names of the imported protos in generated code don't contain dashes.
  45. [ "`cat PluginTest/TestDashFilename.pbrpc.h |
  46. egrep '#import ".*\.pb(objc|rpc)\.h"$' |
  47. egrep '-'`" ] && {
  48. echo >&2 "protoc generated import with wrong filename."
  49. exit 1
  50. }
  51. [ "`cat PluginTest/TestDashFilename.pbrpc.m |
  52. egrep '#import ".*\.pb(objc|rpc)\.h"$' |
  53. egrep '-'`" ] && {
  54. echo >&2 "protoc generated import with wrong filename."
  55. exit 1
  56. }
  57. # Run one extra command to clear $? before exiting the script to prevent
  58. # failing even when tests pass.
  59. echo "Plugin tests passed."