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

Commit 3a0355f9 authored by Liz Kammer's avatar Liz Kammer Committed by Gerrit Code Review
Browse files

Merge "export common bp2build testing functions"

parents 075571b5 3177a6e1
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -94,6 +94,10 @@ func (ll *LabelList) IsNil() bool {
	return ll.Includes == nil && ll.Excludes == nil
}

func (ll *LabelList) IsEmpty() bool {
	return len(ll.Includes) == 0 && len(ll.Excludes) == 0
}

func (ll *LabelList) deepCopy() LabelList {
	return LabelList{
		Includes: ll.Includes[:],
+10 −10
Original line number Diff line number Diff line
@@ -21,28 +21,28 @@ import (
	"testing"
)

func runAndroidAppCertificateTestCase(t *testing.T, tc bp2buildTestCase) {
func runAndroidAppCertificateTestCase(t *testing.T, tc Bp2buildTestCase) {
	t.Helper()
	runBp2BuildTestCase(t, registerAndroidAppCertificateModuleTypes, tc)
	RunBp2BuildTestCase(t, registerAndroidAppCertificateModuleTypes, tc)
}

func registerAndroidAppCertificateModuleTypes(ctx android.RegistrationContext) {
}

func TestAndroidAppCertificateSimple(t *testing.T) {
	runAndroidAppCertificateTestCase(t, bp2buildTestCase{
		description:                "Android app certificate - simple example",
		moduleTypeUnderTest:        "android_app_certificate",
		moduleTypeUnderTestFactory: java.AndroidAppCertificateFactory,
		filesystem:                 map[string]string{},
		blueprint: `
	runAndroidAppCertificateTestCase(t, Bp2buildTestCase{
		Description:                "Android app certificate - simple example",
		ModuleTypeUnderTest:        "android_app_certificate",
		ModuleTypeUnderTestFactory: java.AndroidAppCertificateFactory,
		Filesystem:                 map[string]string{},
		Blueprint: `
android_app_certificate {
        name: "com.android.apogee.cert",
        certificate: "chamber_of_secrets_dir",
}
`,
		expectedBazelTargets: []string{
			makeBazelTargetNoRestrictions("android_app_certificate", "com.android.apogee.cert", attrNameToString{
		ExpectedBazelTargets: []string{
			MakeBazelTargetNoRestrictions("android_app_certificate", "com.android.apogee.cert", AttrNameToString{
				"certificate": `"chamber_of_secrets_dir"`,
			}),
		}})
+26 −26
Original line number Diff line number Diff line
@@ -21,33 +21,33 @@ import (
	"testing"
)

func runAndroidAppTestCase(t *testing.T, tc bp2buildTestCase) {
func runAndroidAppTestCase(t *testing.T, tc Bp2buildTestCase) {
	t.Helper()
	runBp2BuildTestCase(t, registerAndroidAppModuleTypes, tc)
	RunBp2BuildTestCase(t, registerAndroidAppModuleTypes, tc)
}

func registerAndroidAppModuleTypes(ctx android.RegistrationContext) {
}

func TestMinimalAndroidApp(t *testing.T) {
	runAndroidAppTestCase(t, bp2buildTestCase{
		description:                "Android app - simple example",
		moduleTypeUnderTest:        "android_app",
		moduleTypeUnderTestFactory: java.AndroidAppFactory,
		filesystem: map[string]string{
	runAndroidAppTestCase(t, Bp2buildTestCase{
		Description:                "Android app - simple example",
		ModuleTypeUnderTest:        "android_app",
		ModuleTypeUnderTestFactory: java.AndroidAppFactory,
		Filesystem: map[string]string{
			"app.java":            "",
			"res/res.png":         "",
			"AndroidManifest.xml": "",
		},
		blueprint: `
		Blueprint: `
android_app {
        name: "TestApp",
        srcs: ["app.java"],
        sdk_version: "current",
}
`,
		expectedBazelTargets: []string{
			makeBazelTarget("android_binary", "TestApp", attrNameToString{
		ExpectedBazelTargets: []string{
			makeBazelTarget("android_binary", "TestApp", AttrNameToString{
				"srcs":           `["app.java"]`,
				"manifest":       `"AndroidManifest.xml"`,
				"resource_files": `["res/res.png"]`,
@@ -56,17 +56,17 @@ android_app {
}

func TestAndroidAppAllSupportedFields(t *testing.T) {
	runAndroidAppTestCase(t, bp2buildTestCase{
		description:                "Android app - all supported fields",
		moduleTypeUnderTest:        "android_app",
		moduleTypeUnderTestFactory: java.AndroidAppFactory,
		filesystem: map[string]string{
	runAndroidAppTestCase(t, Bp2buildTestCase{
		Description:                "Android app - all supported fields",
		ModuleTypeUnderTest:        "android_app",
		ModuleTypeUnderTestFactory: java.AndroidAppFactory,
		Filesystem: map[string]string{
			"app.java":                     "",
			"resa/res.png":                 "",
			"resb/res.png":                 "",
			"manifest/AndroidManifest.xml": "",
		},
		blueprint: simpleModuleDoNotConvertBp2build("android_app", "static_lib_dep") + `
		Blueprint: simpleModuleDoNotConvertBp2build("android_app", "static_lib_dep") + `
android_app {
        name: "TestApp",
        srcs: ["app.java"],
@@ -78,8 +78,8 @@ android_app {
        java_version: "7",
}
`,
		expectedBazelTargets: []string{
			makeBazelTarget("android_binary", "TestApp", attrNameToString{
		ExpectedBazelTargets: []string{
			makeBazelTarget("android_binary", "TestApp", AttrNameToString{
				"srcs":     `["app.java"]`,
				"manifest": `"manifest/AndroidManifest.xml"`,
				"resource_files": `[
@@ -94,17 +94,17 @@ android_app {
}

func TestAndroidAppArchVariantSrcs(t *testing.T) {
	runAndroidAppTestCase(t, bp2buildTestCase{
		description:                "Android app - arch variant srcs",
		moduleTypeUnderTest:        "android_app",
		moduleTypeUnderTestFactory: java.AndroidAppFactory,
		filesystem: map[string]string{
	runAndroidAppTestCase(t, Bp2buildTestCase{
		Description:                "Android app - arch variant srcs",
		ModuleTypeUnderTest:        "android_app",
		ModuleTypeUnderTestFactory: java.AndroidAppFactory,
		Filesystem: map[string]string{
			"arm.java":            "",
			"x86.java":            "",
			"res/res.png":         "",
			"AndroidManifest.xml": "",
		},
		blueprint: `
		Blueprint: `
android_app {
        name: "TestApp",
        sdk_version: "current",
@@ -118,8 +118,8 @@ android_app {
		}
}
`,
		expectedBazelTargets: []string{
			makeBazelTarget("android_binary", "TestApp", attrNameToString{
		ExpectedBazelTargets: []string{
			makeBazelTarget("android_binary", "TestApp", AttrNameToString{
				"srcs": `select({
        "//build/bazel/platforms/arch:arm": ["arm.java"],
        "//build/bazel/platforms/arch:x86": ["x86.java"],
+170 −170

File changed.

Preview size limit exceeded, changes collapsed.

+9 −9
Original line number Diff line number Diff line
@@ -21,28 +21,28 @@ import (
	"testing"
)

func runApexKeyTestCase(t *testing.T, tc bp2buildTestCase) {
func runApexKeyTestCase(t *testing.T, tc Bp2buildTestCase) {
	t.Helper()
	runBp2BuildTestCase(t, registerApexKeyModuleTypes, tc)
	RunBp2BuildTestCase(t, registerApexKeyModuleTypes, tc)
}

func registerApexKeyModuleTypes(ctx android.RegistrationContext) {
}

func TestApexKeySimple(t *testing.T) {
	runApexKeyTestCase(t, bp2buildTestCase{
		description:                "apex key - simple example",
		moduleTypeUnderTest:        "apex_key",
		moduleTypeUnderTestFactory: apex.ApexKeyFactory,
		filesystem:                 map[string]string{},
		blueprint: `
	runApexKeyTestCase(t, Bp2buildTestCase{
		Description:                "apex key - simple example",
		ModuleTypeUnderTest:        "apex_key",
		ModuleTypeUnderTestFactory: apex.ApexKeyFactory,
		Filesystem:                 map[string]string{},
		Blueprint: `
apex_key {
        name: "com.android.apogee.key",
        public_key: "com.android.apogee.avbpubkey",
        private_key: "com.android.apogee.pem",
}
`,
		expectedBazelTargets: []string{makeBazelTargetNoRestrictions("apex_key", "com.android.apogee.key", attrNameToString{
		ExpectedBazelTargets: []string{MakeBazelTargetNoRestrictions("apex_key", "com.android.apogee.key", AttrNameToString{
			"private_key": `"com.android.apogee.pem"`,
			"public_key":  `"com.android.apogee.avbpubkey"`,
		}),
Loading