export common bp2build testing functions
bp2buildTestCase
attrNameToString
runBp2BuildTestCase
makeBazelTargetNoRestrictions
The testing framework defined in the bp2build package can only be used
from within the package because many common testing functions are
private to the package. This prevents modules defined in Soong
plugins (e.g. system/tools/aidl/build) from testing bp2build conversions.
Test: go test ./bp2build
Change-Id: Ia867081327c5181d04687b13c4550e68e6a11f86
diff --git a/bp2build/sh_conversion_test.go b/bp2build/sh_conversion_test.go
index ac89087..d8f701d 100644
--- a/bp2build/sh_conversion_test.go
+++ b/bp2build/sh_conversion_test.go
@@ -48,25 +48,25 @@
}
}
-func runShBinaryTestCase(t *testing.T, tc bp2buildTestCase) {
+func runShBinaryTestCase(t *testing.T, tc Bp2buildTestCase) {
t.Helper()
- runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, tc)
+ RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, tc)
}
func TestShBinarySimple(t *testing.T) {
- runShBinaryTestCase(t, bp2buildTestCase{
- description: "sh_binary test",
- moduleTypeUnderTest: "sh_binary",
- moduleTypeUnderTestFactory: sh.ShBinaryFactory,
- blueprint: `sh_binary {
+ runShBinaryTestCase(t, Bp2buildTestCase{
+ Description: "sh_binary test",
+ ModuleTypeUnderTest: "sh_binary",
+ ModuleTypeUnderTestFactory: sh.ShBinaryFactory,
+ Blueprint: `sh_binary {
name: "foo",
src: "foo.sh",
filename: "foo.exe",
sub_dir: "sub",
bazel_module: { bp2build_available: true },
}`,
- expectedBazelTargets: []string{
- makeBazelTarget("sh_binary", "foo", attrNameToString{
+ ExpectedBazelTargets: []string{
+ makeBazelTarget("sh_binary", "foo", AttrNameToString{
"srcs": `["foo.sh"]`,
"filename": `"foo.exe"`,
"sub_dir": `"sub"`,
@@ -75,17 +75,17 @@
}
func TestShBinaryDefaults(t *testing.T) {
- runShBinaryTestCase(t, bp2buildTestCase{
- description: "sh_binary test",
- moduleTypeUnderTest: "sh_binary",
- moduleTypeUnderTestFactory: sh.ShBinaryFactory,
- blueprint: `sh_binary {
+ runShBinaryTestCase(t, Bp2buildTestCase{
+ Description: "sh_binary test",
+ ModuleTypeUnderTest: "sh_binary",
+ ModuleTypeUnderTestFactory: sh.ShBinaryFactory,
+ Blueprint: `sh_binary {
name: "foo",
src: "foo.sh",
bazel_module: { bp2build_available: true },
}`,
- expectedBazelTargets: []string{
- makeBazelTarget("sh_binary", "foo", attrNameToString{
+ ExpectedBazelTargets: []string{
+ makeBazelTarget("sh_binary", "foo", AttrNameToString{
"srcs": `["foo.sh"]`,
})},
})