Add test workspace for output_directory file copying #213

This commit is contained in:
Adam Liddell 2022-08-23 23:08:23 +01:00
parent a7030e0a67
commit b66ebdb1fa
7 changed files with 98 additions and 1 deletions

View File

@ -564,6 +564,7 @@ tasks:
- make test_workspace_go_fixer
- make test_workspace_go_importpath
- make test_workspace_import_prefix
- make test_workspace_nested_output_directory
- make test_workspace_objc_capitalisation
- make test_workspace_python3_grpc
- make test_workspace_python_dashes
@ -587,6 +588,7 @@ tasks:
- make test_workspace_go_fixer
- make test_workspace_go_importpath
- make test_workspace_import_prefix
- make test_workspace_nested_output_directory
- make test_workspace_objc_capitalisation
- make test_workspace_python3_grpc
- make test_workspace_python_dashes

View File

@ -43,6 +43,11 @@ test_workspace_import_prefix:
cd test_workspaces/import_prefix; \
bazel --batch test --host_cxxopt=-std=c++17 ${BAZEL_EXTRA_FLAGS} --verbose_failures --disk_cache=../bazel-disk-cache --test_output=errors //...
.PHONY: test_workspace_nested_output_directory
test_workspace_nested_output_directory:
cd test_workspaces/nested_output_directory; \
bazel --batch test --host_cxxopt=-std=c++17 ${BAZEL_EXTRA_FLAGS} --verbose_failures --disk_cache=../bazel-disk-cache --test_output=errors //...
.PHONY: test_workspace_objc_capitalisation
test_workspace_objc_capitalisation:
cd test_workspaces/objc_capitalisation; \
@ -84,4 +89,4 @@ test_workspace_typescript:
bazel --batch test --host_cxxopt=-std=c++17 ${BAZEL_EXTRA_FLAGS} --verbose_failures --disk_cache=../bazel-disk-cache --test_output=errors //...
.PHONY: all_test_workspaces
all_test_workspaces: test_workspace_absolute_strip_import_prefix test_workspace_combined_strip_and_add_prefix test_workspace_common_cpp_library test_workspace_empty_output_directory test_workspace_exclusions test_workspace_generated_proto test_workspace_go_fixer test_workspace_go_importpath test_workspace_import_prefix test_workspace_objc_capitalisation test_workspace_python3_grpc test_workspace_python_dashes test_workspace_python_deps test_workspace_readme_http_archive test_workspace_relative_strip_import_prefix test_workspace_shared_proto test_workspace_typescript
all_test_workspaces: test_workspace_absolute_strip_import_prefix test_workspace_combined_strip_and_add_prefix test_workspace_common_cpp_library test_workspace_empty_output_directory test_workspace_exclusions test_workspace_generated_proto test_workspace_go_fixer test_workspace_go_importpath test_workspace_import_prefix test_workspace_nested_output_directory test_workspace_objc_capitalisation test_workspace_python3_grpc test_workspace_python_dashes test_workspace_python_deps test_workspace_readme_http_archive test_workspace_relative_strip_import_prefix test_workspace_shared_proto test_workspace_typescript

View File

@ -0,0 +1,27 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:defs.bzl", "py_test")
load("mixed_grpc_compile.bzl", "mixed_grpc_compile")
package(default_visibility = ["//visibility:private"])
# Test that plugins that use output_directory behave correctly when files are in a nested dir
# This needs a mix of both a output_directory plugin and a normal plugin that retains the directory,
# which in this case is Python proto + PHP gRPC
# See https://github.com/rules-proto-grpc/rules_proto_grpc/pull/213
proto_library(
name = "proto_lib",
srcs = ["directory/service.proto"],
)
mixed_grpc_compile(
name = "mixed_lib",
protos = ["proto_lib"],
)
# Some sort of test is required to exit cleanly
py_test(
name = "placeholder",
srcs = ["placeholder.py"],
main = "placeholder.py",
)

View File

@ -0,0 +1,28 @@
local_repository(
name = "rules_proto_grpc",
path = "../../",
)
load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_repos", "rules_proto_grpc_toolchains")
rules_proto_grpc_toolchains()
rules_proto_grpc_repos()
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
rules_proto_dependencies()
rules_proto_toolchains()
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
grpc_deps()
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
grpc_extra_deps()
load("@rules_proto_grpc//csharp:repositories.bzl", rules_proto_grpc_csharp_repos = "csharp_repos")
rules_proto_grpc_csharp_repos()

View File

@ -0,0 +1,9 @@
syntax = "proto3";
message demo {
bool field = 1;
}
service Demo {
rpc Demo (demo) returns (demo);
}

View File

@ -0,0 +1,25 @@
"""Generated definition of mixed_grpc_compile."""
load(
"@rules_proto_grpc//:defs.bzl",
"ProtoPluginInfo",
"proto_compile_attrs",
"proto_compile_impl",
)
# Create compile rule
mixed_grpc_compile = rule(
implementation = proto_compile_impl,
attrs = dict(
proto_compile_attrs,
_plugins = attr.label_list(
providers = [ProtoPluginInfo],
default = [
Label("@rules_proto_grpc//python:python_plugin"),
Label("@rules_proto_grpc//php:grpc_php_plugin"),
],
doc = "List of protoc plugins to apply",
),
),
toolchains = [str(Label("@rules_proto_grpc//protobuf:toolchain_type"))],
)

View File

@ -0,0 +1 @@
# coding=utf-8