Support proto modules with external references.

Bug: 236055697
Test: Manual testing and adding new unit tests.
Change-Id: I984c0ecb93f0023727a39a3af3921820337bf8c7
This commit is contained in:
Yu Liu
2022-09-01 11:54:47 -07:00
parent 8c6f4576ef
commit 2aa806b52d
7 changed files with 291 additions and 73 deletions

View File

@@ -15,10 +15,10 @@
package bp2build
import (
"android/soong/android"
"fmt"
"testing"
"android/soong/android"
)
func runFilegroupTestCase(t *testing.T, tc Bp2buildTestCase) {
@@ -121,3 +121,43 @@ filegroup {
]`}),
}})
}
func TestFilegroupWithProtoSrcs(t *testing.T) {
runFilegroupTestCase(t, Bp2buildTestCase{
Description: "filegroup with proto and non-proto srcs",
Filesystem: map[string]string{},
Blueprint: `
filegroup {
name: "foo",
srcs: ["proto/foo.proto"],
path: "proto",
}`,
ExpectedBazelTargets: []string{
MakeBazelTargetNoRestrictions("proto_library", "foo_bp2build_converted", AttrNameToString{
"srcs": `["proto/foo.proto"]`,
"strip_import_prefix": `"proto"`}),
MakeBazelTargetNoRestrictions("filegroup", "foo", AttrNameToString{
"srcs": `["proto/foo.proto"]`}),
}})
}
func TestFilegroupWithProtoAndNonProtoSrcs(t *testing.T) {
runFilegroupTestCase(t, Bp2buildTestCase{
Description: "filegroup with proto and non-proto srcs",
Filesystem: map[string]string{},
Blueprint: `
filegroup {
name: "foo",
srcs: [
"foo.proto",
"buf.cpp",
],
}`,
ExpectedBazelTargets: []string{
MakeBazelTargetNoRestrictions("filegroup", "foo", AttrNameToString{
"srcs": `[
"foo.proto",
"buf.cpp",
]`}),
}})
}