Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 06ac78ce authored by Christopher Parsons's avatar Christopher Parsons Committed by Gerrit Code Review
Browse files

Merge "Refactor bp2build tests for allowlist v2" into main

parents a1a29b75 cd209035
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -15,10 +15,10 @@
package bp2build

import (
	"testing"

	"android/soong/android"
	"android/soong/java"

	"testing"
)

func TestConvertAndroidLibrary(t *testing.T) {
@@ -34,7 +34,8 @@ func TestConvertAndroidLibrary(t *testing.T) {
			"res/res.png":                  "",
			"manifest/AndroidManifest.xml": "",
		},
		Blueprint: SimpleModuleDoNotConvertBp2build("android_library", "static_lib_dep") + `
		StubbedBuildDefinitions: []string{"static_lib_dep"},
		Blueprint: simpleModule("android_library", "static_lib_dep") + `
android_library {
	name: "TestLib",
	srcs: ["lib.java"],
@@ -81,7 +82,7 @@ func TestConvertAndroidLibraryWithNoSources(t *testing.T) {
			"res/res.png":         "",
			"AndroidManifest.xml": "",
		},
		Blueprint: SimpleModuleDoNotConvertBp2build("android_library", "lib_dep") + `
		Blueprint: simpleModule("android_library", "lib_dep") + `
android_library {
	name: "TestLib",
	srcs: [],
@@ -107,18 +108,24 @@ func TestConvertAndroidLibraryImport(t *testing.T) {
			ModuleTypeUnderTestFactory: java.AARImportFactory,
			Filesystem: map[string]string{
				"import.aar": "",
				"dep.aar":    "",
			},
			StubbedBuildDefinitions: []string{"static_lib_dep", "prebuilt_static_import_dep"},
			// Bazel's aar_import can only export *_import targets, so we expect
			// only "static_import_dep" in exports, but both "static_lib_dep" and
			// "static_import_dep" in deps
			Blueprint: SimpleModuleDoNotConvertBp2build("android_library", "static_lib_dep") +
				SimpleModuleDoNotConvertBp2build("android_library_import", "static_import_dep") + `
			Blueprint: simpleModule("android_library", "static_lib_dep") + `
android_library_import {
        name: "TestImport",
        aars: ["import.aar"],
        static_libs: ["static_lib_dep", "static_import_dep"],
    sdk_version: "current",
}

// TODO: b/301007952 - This dep is needed because android_library_import must have aars set.
android_library_import {
        name: "static_import_dep",
}
`,
			ExpectedBazelTargets: []string{
				MakeBazelTarget(
+10 −6
Original line number Diff line number Diff line
@@ -78,7 +78,8 @@ func TestAndroidAppAllSupportedFields(t *testing.T) {
			"manifest/AndroidManifest.xml": "",
			"assets_/asset.png":            "",
		},
		Blueprint: SimpleModuleDoNotConvertBp2build("android_app", "static_lib_dep") + `
		StubbedBuildDefinitions: []string{"static_lib_dep"},
		Blueprint: simpleModule("android_app", "static_lib_dep") + `
android_app {
	name: "TestApp",
	srcs: ["app.java"],
@@ -177,7 +178,8 @@ func TestAndroidAppCertIsModule(t *testing.T) {
		ModuleTypeUnderTest:        "android_app",
		ModuleTypeUnderTestFactory: java.AndroidAppFactory,
		Filesystem:                 map[string]string{},
		Blueprint: SimpleModuleDoNotConvertBp2build("filegroup", "foocert") + `
		StubbedBuildDefinitions:    []string{"foocert"},
		Blueprint: simpleModule("filegroup", "foocert") + `
android_app {
	name: "TestApp",
	certificate: ":foocert",
@@ -262,7 +264,8 @@ func TestAndroidAppLibs(t *testing.T) {
		ModuleTypeUnderTest:        "android_app",
		ModuleTypeUnderTestFactory: java.AndroidAppFactory,
		Filesystem:                 map[string]string{},
		Blueprint: SimpleModuleDoNotConvertBp2build("java_library", "barLib") + `
		StubbedBuildDefinitions:    []string{"barLib"},
		Blueprint: simpleModule("java_library", "barLib") + `
android_app {
	name: "foo",
	libs: ["barLib"],
@@ -291,8 +294,9 @@ func TestAndroidAppKotlinSrcs(t *testing.T) {
		Filesystem: map[string]string{
			"res/res.png": "",
		},
		Blueprint: SimpleModuleDoNotConvertBp2build("filegroup", "foocert") +
			SimpleModuleDoNotConvertBp2build("java_library", "barLib") + `
		StubbedBuildDefinitions: []string{"foocert", "barLib"},
		Blueprint: simpleModule("filegroup", "foocert") +
			simpleModule("java_library", "barLib") + `
android_app {
	name: "foo",
	srcs: ["a.java", "b.kt"],
@@ -334,6 +338,7 @@ func TestAndroidAppCommonSrcs(t *testing.T) {
		Filesystem: map[string]string{
			"res/res.png": "",
		},
		StubbedBuildDefinitions: []string{"barLib"},
		Blueprint: `
android_app {
	name: "foo",
@@ -348,7 +353,6 @@ android_app {
}
java_library{
	name:   "barLib",
	bazel_module: { bp2build_available: false },
}
`,
		ExpectedBazelTargets: []string{
+54 −80

File changed.

Preview size limit exceeded, changes collapsed.

+3 −2
Original line number Diff line number Diff line
@@ -83,14 +83,15 @@ func TestApexKey_KeysAreModules(t *testing.T) {
		ModuleTypeUnderTest:        "apex_key",
		ModuleTypeUnderTestFactory: apex.ApexKeyFactory,
		Filesystem:                 map[string]string{},
		StubbedBuildDefinitions:    []string{"com.android.apogee.avbpubkey", "com.android.apogee.pem"},
		Blueprint: `
apex_key {
        name: "com.android.apogee.key",
        public_key: ":com.android.apogee.avbpubkey",
        private_key: ":com.android.apogee.pem",
}
` + SimpleModuleDoNotConvertBp2build("filegroup", "com.android.apogee.avbpubkey") +
			SimpleModuleDoNotConvertBp2build("filegroup", "com.android.apogee.pem"),
` + simpleModule("filegroup", "com.android.apogee.avbpubkey") +
			simpleModule("filegroup", "com.android.apogee.pem"),
		ExpectedBazelTargets: []string{MakeBazelTargetNoRestrictions("apex_key", "com.android.apogee.key", AttrNameToString{
			"private_key":            `":com.android.apogee.pem"`,
			"public_key":             `":com.android.apogee.avbpubkey"`,
+11 −6
Original line number Diff line number Diff line
@@ -1743,7 +1743,8 @@ func TestCommonBp2BuildModuleAttrs(t *testing.T) {
			Description:                "Required into data test",
			ModuleTypeUnderTest:        "filegroup",
			ModuleTypeUnderTestFactory: android.FileGroupFactory,
			Blueprint: SimpleModuleDoNotConvertBp2build("filegroup", "reqd") + `
			StubbedBuildDefinitions:    []string{"reqd"},
			Blueprint: simpleModule("filegroup", "reqd") + `
filegroup {
    name: "fg_foo",
    required: ["reqd"],
@@ -1759,7 +1760,8 @@ filegroup {
			Description:                "Required into data test, cyclic self reference is filtered out",
			ModuleTypeUnderTest:        "filegroup",
			ModuleTypeUnderTestFactory: android.FileGroupFactory,
			Blueprint: SimpleModuleDoNotConvertBp2build("filegroup", "reqd") + `
			StubbedBuildDefinitions:    []string{"reqd"},
			Blueprint: simpleModule("filegroup", "reqd") + `
filegroup {
    name: "fg_foo",
    required: ["reqd", "fg_foo"],
@@ -1775,8 +1777,9 @@ filegroup {
			Description:                "Required via arch into data test",
			ModuleTypeUnderTest:        "python_library",
			ModuleTypeUnderTestFactory: python.PythonLibraryFactory,
			Blueprint: SimpleModuleDoNotConvertBp2build("python_library", "reqdx86") +
				SimpleModuleDoNotConvertBp2build("python_library", "reqdarm") + `
			StubbedBuildDefinitions:    []string{"reqdx86", "reqdarm"},
			Blueprint: simpleModule("python_library", "reqdx86") +
				simpleModule("python_library", "reqdarm") + `
python_library {
    name: "fg_foo",
    arch: {
@@ -1809,7 +1812,8 @@ python_library {
				"data.bin": "",
				"src.py":   "",
			},
			Blueprint: SimpleModuleDoNotConvertBp2build("python_library", "reqd") + `
			StubbedBuildDefinitions: []string{"reqd"},
			Blueprint: simpleModule("python_library", "reqd") + `
python_library {
    name: "fg_foo",
    data: ["data.bin"],
@@ -1831,7 +1835,8 @@ python_library {
			Description:                "All props-to-attrs at once together test",
			ModuleTypeUnderTest:        "filegroup",
			ModuleTypeUnderTestFactory: android.FileGroupFactory,
			Blueprint: SimpleModuleDoNotConvertBp2build("filegroup", "reqd") + `
			StubbedBuildDefinitions:    []string{"reqd"},
			Blueprint: simpleModule("filegroup", "reqd") + `
filegroup {
    name: "fg_foo",
    required: ["reqd"],
Loading