diff --git a/bazel/cc_grpc_library.bzl b/bazel/cc_grpc_library.bzl index 94781ed7ae5..5216a7a44b5 100644 --- a/bazel/cc_grpc_library.bzl +++ b/bazel/cc_grpc_library.bzl @@ -2,7 +2,7 @@ load("//:bazel/generate_cc.bzl", "generate_cc") -def cc_grpc_library(name, srcs, deps, proto_only, well_known_protos, generate_mock, use_external = False, **kwargs): +def cc_grpc_library(name, srcs, deps, proto_only, well_known_protos, generate_mocks = False, use_external = False, **kwargs): """Generates C++ grpc classes from a .proto file. Assumes the generated classes will be used in cc_api_version = 2. @@ -16,7 +16,7 @@ def cc_grpc_library(name, srcs, deps, proto_only, well_known_protos, generate_mo protos use_external: When True the grpc deps are prefixed with //external. This allows grpc to be used as a dependency in other bazel projects. - generate_mock: When true GMOCk code for client stub is generated. + generate_mocks: When True, Google Mock code for client stub is generated. **kwargs: rest of arguments, e.g., compatible_with and visibility. """ if len(srcs) > 1: @@ -54,7 +54,7 @@ def cc_grpc_library(name, srcs, deps, proto_only, well_known_protos, generate_mo srcs = [proto_target], plugin = plugin, well_known_protos = well_known_protos, - generate_mock = generate_mock, + generate_mocks = generate_mocks, **kwargs ) diff --git a/bazel/generate_cc.bzl b/bazel/generate_cc.bzl index f88ee2f56f1..e610123dc50 100644 --- a/bazel/generate_cc.bzl +++ b/bazel/generate_cc.bzl @@ -14,7 +14,7 @@ def generate_cc_impl(ctx): if ctx.executable.plugin: outs += [proto.path[label_len:-len(".proto")] + ".grpc.pb.h" for proto in protos] outs += [proto.path[label_len:-len(".proto")] + ".grpc.pb.cc" for proto in protos] - if ctx.attr.generate_mock: + if ctx.attr.generate_mocks: outs += [proto.path[label_len:-len(".proto")] + "_mock.grpc.pb.h" for proto in protos] else: outs += [proto.path[label_len:-len(".proto")] + ".pb.h" for proto in protos] @@ -26,7 +26,7 @@ def generate_cc_impl(ctx): if ctx.executable.plugin: arguments += ["--plugin=protoc-gen-PLUGIN=" + ctx.executable.plugin.path] flags = list(ctx.attr.flags) - if ctx.attr.generate_mock: + if ctx.attr.generate_mocks: flags.append("generate_mock_code=true") arguments += ["--PLUGIN_out=" + ",".join(flags) + ":" + dir_out] additional_input = [ctx.executable.plugin] @@ -76,7 +76,7 @@ _generate_cc = rule( "well_known_protos" : attr.label( mandatory = False, ), - "generate_mock" : attr.bool( + "generate_mocks" : attr.bool( default = False, mandatory = False, ), diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index 571b29cc09b..08dc3de0ea8 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -97,7 +97,7 @@ def grpc_proto_plugin(name, srcs = [], deps = []): load("//:bazel/cc_grpc_library.bzl", "cc_grpc_library") def grpc_proto_library(name, srcs = [], deps = [], well_known_protos = False, - has_services = True, use_external = False, generate_mock = False): + has_services = True, use_external = False, generate_mocks = False): cc_grpc_library( name = name, srcs = srcs, @@ -105,7 +105,7 @@ def grpc_proto_library(name, srcs = [], deps = [], well_known_protos = False, well_known_protos = well_known_protos, proto_only = not has_services, use_external = use_external, - generate_mock = generate_mock, + generate_mocks = generate_mocks, ) def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data = [], uses_polling = True, language = "C++"): diff --git a/doc/unit_testing.md b/doc/unit_testing.md index 0aa9be9b9dc..ca5648130ce 100644 --- a/doc/unit_testing.md +++ b/doc/unit_testing.md @@ -56,7 +56,7 @@ Such a mock can be auto-generated by: 1. Setting flag(generate_mock_code=true) on grpc plugin for protoc, or -1. Setting an attribute(generate_mock) in your bazel rule. +1. Setting an attribute(generate_mocks) in your bazel rule. Protoc plugin flag: @@ -70,7 +70,7 @@ Bazel rule: grpc_proto_library( name = "echo_proto", srcs = ["echo.proto"], - generate_mock = True, + generate_mocks = True, ) ``` diff --git a/src/proto/grpc/testing/BUILD b/src/proto/grpc/testing/BUILD index b8e9a22ab39..58412ed6308 100644 --- a/src/proto/grpc/testing/BUILD +++ b/src/proto/grpc/testing/BUILD @@ -26,7 +26,7 @@ exports_files([ grpc_proto_library( name = "compiler_test_proto", srcs = ["compiler_test.proto"], - generate_mock = True, + generate_mocks = True, ) grpc_proto_library( @@ -49,7 +49,7 @@ grpc_proto_library( name = "echo_proto", srcs = ["echo.proto"], deps = ["echo_messages_proto"], - generate_mock = True, + generate_mocks = True, ) grpc_proto_library(