Refactor bp2build tests for allowlist v2
Allowlist v2 will change bp2build by automatically disabling rdeps of unconvertible modules. Many bp2build tests create bp2build stub modules without an implementation, This CL changes setup of such tests to also contain a BUILD file with "stub implementations" of equivalent targets, to keep these test targets convertible. To verify this change in-place, this CL removes `bp2build_available: false` from these dependencies. This is a test-only change for bp2build tests. Bug: 285631638 Test: m bp2build Change-Id: I489480cbc4158a416b7abf57c35a6e2bc2ad6173
This commit is contained in:
@@ -69,6 +69,7 @@ java_library {
|
||||
|
||||
func TestJavaLibraryConvertsStaticLibsToDepsAndExports(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
StubbedBuildDefinitions: []string{"java-lib-2", "java-lib-3"},
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
srcs: ["a.java"],
|
||||
@@ -82,14 +83,12 @@ java_library {
|
||||
name: "java-lib-2",
|
||||
srcs: ["b.java"],
|
||||
sdk_version: "current",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "java-lib-3",
|
||||
srcs: ["c.java"],
|
||||
sdk_version: "current",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
@@ -108,6 +107,7 @@ java_library {
|
||||
|
||||
func TestJavaLibraryConvertsStaticLibsToExportsIfNoSrcs(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
StubbedBuildDefinitions: []string{"java-lib-2"},
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
static_libs: ["java-lib-2"],
|
||||
@@ -118,7 +118,6 @@ func TestJavaLibraryConvertsStaticLibsToExportsIfNoSrcs(t *testing.T) {
|
||||
java_library {
|
||||
name: "java-lib-2",
|
||||
srcs: ["a.java"],
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
@@ -144,6 +143,7 @@ java_library {
|
||||
|
||||
func TestJavaLibraryPlugins(t *testing.T) {
|
||||
runJavaLibraryTestCaseWithRegistrationCtxFunc(t, Bp2buildTestCase{
|
||||
StubbedBuildDefinitions: []string{"java-plugin-1"},
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
plugins: ["java-plugin-1"],
|
||||
@@ -154,7 +154,6 @@ func TestJavaLibraryPlugins(t *testing.T) {
|
||||
java_plugin {
|
||||
name: "java-plugin-1",
|
||||
srcs: ["a.java"],
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
@@ -195,6 +194,7 @@ func TestJavaLibraryJavaVersion(t *testing.T) {
|
||||
|
||||
func TestJavaLibraryErrorproneEnabledManually(t *testing.T) {
|
||||
runJavaLibraryTestCaseWithRegistrationCtxFunc(t, Bp2buildTestCase{
|
||||
StubbedBuildDefinitions: []string{"plugin2"},
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
srcs: ["a.java"],
|
||||
@@ -209,7 +209,6 @@ func TestJavaLibraryErrorproneEnabledManually(t *testing.T) {
|
||||
java_plugin {
|
||||
name: "plugin2",
|
||||
srcs: ["a.java"],
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
@@ -420,13 +419,12 @@ func TestJavaLibraryResourcesExcludeFile(t *testing.T) {
|
||||
func TestJavaLibraryResourcesWithMultipleDirs(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
Filesystem: map[string]string{
|
||||
"res/a.res": "",
|
||||
"res1/b.res": "",
|
||||
"res2/b.java": "",
|
||||
"res/a.res": "",
|
||||
"res1/b.res": "",
|
||||
},
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
java_resource_dirs: ["res", "res1", "res2"],
|
||||
java_resource_dirs: ["res", "res1"],
|
||||
sdk_version: "current",
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
@@ -619,6 +617,7 @@ func TestJavaLibraryAidlNonAdjacentAidlFilegroup(t *testing.T) {
|
||||
Description: "java_library with non adjacent aidl filegroup",
|
||||
ModuleTypeUnderTest: "java_library",
|
||||
ModuleTypeUnderTestFactory: java.LibraryFactory,
|
||||
StubbedBuildDefinitions: []string{"A_aidl"},
|
||||
Filesystem: map[string]string{
|
||||
"path/to/A/Android.bp": `
|
||||
filegroup {
|
||||
@@ -656,7 +655,7 @@ func TestConvertArmNeonVariant(t *testing.T) {
|
||||
Description: "Android Library - simple arch feature",
|
||||
ModuleTypeUnderTest: "android_library",
|
||||
ModuleTypeUnderTestFactory: java.AndroidLibraryFactory,
|
||||
Blueprint: SimpleModuleDoNotConvertBp2build("android_library", "static_lib_dep") + `
|
||||
Blueprint: simpleModule("android_library", "static_lib_dep") + `
|
||||
android_library {
|
||||
name: "TestLib",
|
||||
manifest: "manifest/AndroidManifest.xml",
|
||||
@@ -694,7 +693,7 @@ func TestConvertMultipleArchFeatures(t *testing.T) {
|
||||
Description: "Android Library - multiple arch features",
|
||||
ModuleTypeUnderTest: "android_library",
|
||||
ModuleTypeUnderTestFactory: java.AndroidLibraryFactory,
|
||||
Blueprint: SimpleModuleDoNotConvertBp2build("android_library", "static_lib_dep") + `
|
||||
Blueprint: simpleModule("android_library", "static_lib_dep") + `
|
||||
android_library {
|
||||
name: "TestLib",
|
||||
manifest: "manifest/AndroidManifest.xml",
|
||||
@@ -740,7 +739,7 @@ func TestConvertExcludeSrcsArchFeature(t *testing.T) {
|
||||
Description: "Android Library - exclude_srcs with arch feature",
|
||||
ModuleTypeUnderTest: "android_library",
|
||||
ModuleTypeUnderTestFactory: java.AndroidLibraryFactory,
|
||||
Blueprint: SimpleModuleDoNotConvertBp2build("android_library", "static_lib_dep") + `
|
||||
Blueprint: simpleModule("android_library", "static_lib_dep") + `
|
||||
android_library {
|
||||
name: "TestLib",
|
||||
manifest: "manifest/AndroidManifest.xml",
|
||||
@@ -848,33 +847,10 @@ func TestJavaLibraryKotlinCommonSrcs(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestJavaLibraryLibsWithNoSrcs(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
Description: "java_library that has libs but no srcs",
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
libs: ["java-lib-2"],
|
||||
sdk_version: "current",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
|
||||
java_library{
|
||||
name: "java-lib-2",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestJavaLibraryArchVariantDeps(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
Description: "java_library with arch variant libs",
|
||||
Description: "java_library with arch variant libs",
|
||||
StubbedBuildDefinitions: []string{"java-lib-2", "java-lib-3", "java-lib-4"},
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
srcs: ["a.java"],
|
||||
@@ -891,17 +867,14 @@ func TestJavaLibraryArchVariantDeps(t *testing.T) {
|
||||
|
||||
java_library{
|
||||
name: "java-lib-2",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
java_library{
|
||||
name: "java-lib-3",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
java_library{
|
||||
name: "java-lib-4",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
@@ -1050,14 +1023,3 @@ filegroup {
|
||||
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
|
||||
})
|
||||
}
|
||||
|
||||
func TestJavaSdkVersionCorePlatformDoesNotConvert(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
sdk_version: "core_platform",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{},
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user