-
-
Notifications
You must be signed in to change notification settings - Fork 668
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Infer importpath if not set explicitly (#3705)
* Infer importpath if not set explicitely * Add test with explicit and implicit importpath --------- Co-authored-by: Zhongpeng Lin <[email protected]>
- Loading branch information
Showing
7 changed files
with
85 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") | ||
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") | ||
load("@rules_proto//proto:defs.bzl", "proto_library") | ||
|
||
# Common rules | ||
proto_library( | ||
name = "foo_proto", | ||
srcs = ["foo.proto"], | ||
) | ||
|
||
go_proto_library( | ||
name = "foo_go_proto", | ||
importpath = "path/to/foo_go", | ||
proto = ":foo_proto", | ||
) | ||
|
||
proto_library( | ||
name = "bar_proto", | ||
srcs = ["bar.proto"], | ||
deps = [":foo_proto"], | ||
) | ||
|
||
go_proto_library( | ||
name = "bar_go_proto", | ||
proto = ":bar_proto", | ||
deps = [":foo_go_proto"], | ||
) | ||
|
||
go_test( | ||
name = "importpath_test", | ||
srcs = ["importpath_test.go"], | ||
deps = [ | ||
":bar_go_proto", | ||
":foo_go_proto", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
syntax = "proto3"; | ||
|
||
package tests.core.go_proto_library_importpath.bar; | ||
|
||
import "tests/core/go_proto_library_importpath/foo.proto"; | ||
|
||
message Bar { | ||
foo.Foo value = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
syntax = "proto3"; | ||
|
||
package tests.core.go_proto_library_importpath.foo; | ||
|
||
message Foo { | ||
int64 value = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package importpath_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
bar_proto "tests/core/go_proto_library_importpath/bar_go_proto" | ||
foo_proto "path/to/foo_go" | ||
) | ||
|
||
func Test(t *testing.T) { | ||
bar := &bar_proto.Bar{} | ||
bar.Value = &foo_proto.Foo{} | ||
bar.Value.Value = 5 | ||
|
||
var expected int64 = 5 | ||
if bar.Value.Value != expected { | ||
t.Errorf(fmt.Sprintf("Not equal: \n"+ | ||
"expected: %s\n"+ | ||
"actual : %s", expected, bar.Value.Value)) | ||
} | ||
} |