Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions proto/def.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ go_proto_library = go_rule(
),
"importpath": attr.string(),
"importmap": attr.string(),
"importpath_aliases": attr.string_list(), # experimental, undocumented
"embed": attr.label_list(providers = [GoLibrary]),
"gc_goopts": attr.string_list(),
"compiler": attr.label(providers = [GoProtoCompiler]),
Expand Down
7 changes: 7 additions & 0 deletions tests/core/go_proto_library/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,16 @@ go_test(
deps = [":protos_go_proto"],
)

go_test(
Comment thread
tian000 marked this conversation as resolved.
name = "protos_alias_test",
srcs = ["protos_alias_test.go"],
deps = [":protos_go_proto"],
)

go_proto_library(
name = "protos_go_proto",
importpath = "github.com/bazelbuild/rules_go/tests/core/go_proto_library/protos",
importpath_aliases = ["myalias/protos"],
protos = [
":protos_a_proto",
":protos_b_proto",
Expand Down
6 changes: 6 additions & 0 deletions tests/core/go_proto_library/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@ wkt_wrapper_test
Checks that most of the well known types in ``//proto/wkt`` are wrappers
for packages in ``@org_golang_google_protobuf``. The proto types should be
type aliases.

protos_alias_test
-----------------

Checks that packages generated by `go_proto_library` can be imported using one of the strings
listed in ``importpath_aliases``.
29 changes: 29 additions & 0 deletions tests/core/go_proto_library/protos_alias_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* Copyright 2020 The Bazel Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package protos_alias_test

import (
"myalias/protos" // importing based on the alias import path
"testing"
)

func use(interface{}) {}

func TestProtos(t *testing.T) {
// just make sure both types exist
use(protos.A{})
use(protos.B{})
}