Rename generate_mock to generate_mocks

pull/14784/head
yang-g 7 years ago
parent 1cf6311258
commit 502ba74868
  1. 6
      bazel/cc_grpc_library.bzl
  2. 6
      bazel/generate_cc.bzl
  3. 4
      bazel/grpc_build_system.bzl
  4. 4
      doc/unit_testing.md
  5. 4
      src/proto/grpc/testing/BUILD

@ -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 GMOCk 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
)

@ -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,
),

@ -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++"):

@ -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,
)
```

@ -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(

Loading…
Cancel
Save