diff --git a/ts/private/ts_proto_library.bzl b/ts/private/ts_proto_library.bzl index ccd08927..77884c77 100644 --- a/ts/private/ts_proto_library.bzl +++ b/ts/private/ts_proto_library.bzl @@ -47,7 +47,7 @@ def _protoc_action(ctx, proto_info, outputs): args.add_joined(["--connect-query_out", ctx.bin_dir.path], join_with = "=") args.add("--descriptor_set_in") - args.add_joined(proto_info.transitive_descriptor_sets, join_with = ":") + args.add_joined(proto_info.transitive_descriptor_sets, join_with = ctx.configuration.host_path_separator) args.add_all(proto_info.direct_sources) diff --git a/ts/test/BUILD.bazel b/ts/test/BUILD.bazel index 9d73d734..84528371 100644 --- a/ts/test/BUILD.bazel +++ b/ts/test/BUILD.bazel @@ -4,6 +4,7 @@ load(":flags_test.bzl", "ts_project_flags_test_suite") load(":mock_transpiler.bzl", "mock") load(":transpiler_tests.bzl", "transpiler_test_suite") load(":ts_project_test.bzl", "ts_project_test_suite") +load(":ts_proto_library_test.bzl", "ts_proto_library_test_suite") transpiler_test_suite() @@ -11,6 +12,8 @@ ts_project_test_suite(name = "ts_project_test") ts_project_flags_test_suite(name = "ts_project_flags_test") +ts_proto_library_test_suite(name = "ts_proto_library_test") + # Ensure that when determining output location, the `root_dir` attribute is only removed once. ts_project( name = "rootdir_works_with_repeated_directory", diff --git a/ts/test/ts_proto_library/BUILD.bazel b/ts/test/ts_proto_library/BUILD.bazel new file mode 100644 index 00000000..b8377383 --- /dev/null +++ b/ts/test/ts_proto_library/BUILD.bazel @@ -0,0 +1,25 @@ +"Proto libraries for ts_proto_library tests." +# These are a concrete package rather than using `write_file` in the test file, +# since protoc would otherwise not find the proto files in the descriptor +# database. + +proto_library( + name = "bar_proto", + srcs = [ + ":bar.proto", + ], + tags = ["manual"], + visibility = ["//ts/test:__subpackages__"], +) + +proto_library( + name = "foo_proto", + srcs = [ + ":foo.proto", + ], + tags = ["manual"], + visibility = ["//ts/test:__subpackages__"], + deps = [ + ":bar_proto", + ], +) diff --git a/ts/test/ts_proto_library/bar.proto b/ts/test/ts_proto_library/bar.proto new file mode 100644 index 00000000..f04174d3 --- /dev/null +++ b/ts/test/ts_proto_library/bar.proto @@ -0,0 +1,4 @@ +syntax = "proto3"; +package bar; + +message Bar {} diff --git a/ts/test/ts_proto_library/foo.proto b/ts/test/ts_proto_library/foo.proto new file mode 100644 index 00000000..fb064e0a --- /dev/null +++ b/ts/test/ts_proto_library/foo.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; +package foo; + +import "ts/test/ts_proto_library/bar.proto"; + +message Foo { + bar.Bar bar = 1; +} diff --git a/ts/test/ts_proto_library_test.bzl b/ts/test/ts_proto_library_test.bzl new file mode 100644 index 00000000..83203c3f --- /dev/null +++ b/ts/test/ts_proto_library_test.bzl @@ -0,0 +1,30 @@ +"UnitTest for ts_proto_library" + +load("@bazel_skylib//rules:build_test.bzl", "build_test") +load("//ts:proto.bzl", "ts_proto_library") + +def ts_proto_library_test_suite(name): + """Test suite including all tests and data. + + Args: + name: The name of the test suite. + """ + + ts_proto_library( + name = "ts_proto_library_with_dep", + # The //examples package is the root pnpm package for the repo, so we + # borrow from the proto/grpc example to provide the required + # ts_proto_library npm dependencies. + node_modules = "//examples/proto_grpc:node_modules", + proto = "//ts/test/ts_proto_library:foo_proto", + proto_srcs = ["//ts/test/ts_proto_library:foo.proto"], + # This is disabled to avoid checking in the output files, which are + # implicitly inputs for the copy_file tests. + copy_files = False, + tags = ["manual"], + ) + + build_test( + name = "ts_proto_library_with_dep_test", + targets = [":ts_proto_library_with_dep"], + )