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/java_library_host_conversion_test.go b/bp2build/java_library_host_conversion_test.go
index 83cc551..1dcf163 100644
--- a/bp2build/java_library_host_conversion_test.go
+++ b/bp2build/java_library_host_conversion_test.go
@@ -21,17 +21,17 @@
"android/soong/java"
)
-func runJavaLibraryHostTestCase(t *testing.T, tc bp2buildTestCase) {
+func runJavaLibraryHostTestCase(t *testing.T, tc Bp2buildTestCase) {
t.Helper()
- (&tc).moduleTypeUnderTest = "java_library_host"
- (&tc).moduleTypeUnderTestFactory = java.LibraryHostFactory
- runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, tc)
+ (&tc).ModuleTypeUnderTest = "java_library_host"
+ (&tc).ModuleTypeUnderTestFactory = java.LibraryHostFactory
+ RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, tc)
}
func TestJavaLibraryHost(t *testing.T) {
- runJavaLibraryHostTestCase(t, bp2buildTestCase{
- description: "java_library_host with srcs, exclude_srcs and libs",
- blueprint: `java_library_host {
+ runJavaLibraryHostTestCase(t, Bp2buildTestCase{
+ Description: "java_library_host with srcs, exclude_srcs and libs",
+ Blueprint: `java_library_host {
name: "java-lib-host-1",
srcs: ["a.java", "b.java"],
exclude_srcs: ["b.java"],
@@ -45,8 +45,8 @@
bazel_module: { bp2build_available: true },
java_version: "9",
}`,
- expectedBazelTargets: []string{
- makeBazelTarget("java_library", "java-lib-host-1", attrNameToString{
+ ExpectedBazelTargets: []string{
+ makeBazelTarget("java_library", "java-lib-host-1", AttrNameToString{
"srcs": `["a.java"]`,
"deps": `[":java-lib-host-2"]`,
"target_compatible_with": `select({
@@ -54,7 +54,7 @@
"//conditions:default": [],
})`,
}),
- makeBazelTarget("java_library", "java-lib-host-2", attrNameToString{
+ makeBazelTarget("java_library", "java-lib-host-2", AttrNameToString{
"javacopts": `["-source 1.9 -target 1.9"]`,
"srcs": `["c.java"]`,
"target_compatible_with": `select({