diff --git a/apex/apex_test.go b/apex/apex_test.go index 1006a62c1..898b9e948 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -70,20 +70,16 @@ func testApex(t *testing.T, bp string, handlers ...interface{}) *android.TestCon // deprecated type testCustomizer func(fs map[string][]byte, config android.Config) -func withFiles(files map[string][]byte) testCustomizer { - return func(fs map[string][]byte, config android.Config) { - for k, v := range files { - fs[k] = v - } - } +func withFiles(files android.MockFS) android.FixturePreparer { + return files.AddToFixture() } -func withTargets(targets map[android.OsType][]android.Target) testCustomizer { - return func(fs map[string][]byte, config android.Config) { +func withTargets(targets map[android.OsType][]android.Target) android.FixturePreparer { + return android.FixtureModifyConfig(func(config android.Config) { for k, v := range targets { config.Targets[k] = v } - } + }) } // withNativeBridgeTargets sets configuration with targets including: @@ -91,32 +87,38 @@ func withTargets(targets map[android.OsType][]android.Target) testCustomizer { // - X86 (secondary) // - Arm64 on X86_64 (native bridge) // - Arm on X86 (native bridge) -func withNativeBridgeEnabled(_ map[string][]byte, config android.Config) { - config.Targets[android.Android] = []android.Target{ - {Os: android.Android, Arch: android.Arch{ArchType: android.X86_64, ArchVariant: "silvermont", Abi: []string{"arm64-v8a"}}, - NativeBridge: android.NativeBridgeDisabled, NativeBridgeHostArchName: "", NativeBridgeRelativePath: ""}, - {Os: android.Android, Arch: android.Arch{ArchType: android.X86, ArchVariant: "silvermont", Abi: []string{"armeabi-v7a"}}, - NativeBridge: android.NativeBridgeDisabled, NativeBridgeHostArchName: "", NativeBridgeRelativePath: ""}, - {Os: android.Android, Arch: android.Arch{ArchType: android.Arm64, ArchVariant: "armv8-a", Abi: []string{"arm64-v8a"}}, - NativeBridge: android.NativeBridgeEnabled, NativeBridgeHostArchName: "x86_64", NativeBridgeRelativePath: "arm64"}, - {Os: android.Android, Arch: android.Arch{ArchType: android.Arm, ArchVariant: "armv7-a-neon", Abi: []string{"armeabi-v7a"}}, - NativeBridge: android.NativeBridgeEnabled, NativeBridgeHostArchName: "x86", NativeBridgeRelativePath: "arm"}, - } +var withNativeBridgeEnabled = android.FixtureModifyConfig( + func(config android.Config) { + config.Targets[android.Android] = []android.Target{ + {Os: android.Android, Arch: android.Arch{ArchType: android.X86_64, ArchVariant: "silvermont", Abi: []string{"arm64-v8a"}}, + NativeBridge: android.NativeBridgeDisabled, NativeBridgeHostArchName: "", NativeBridgeRelativePath: ""}, + {Os: android.Android, Arch: android.Arch{ArchType: android.X86, ArchVariant: "silvermont", Abi: []string{"armeabi-v7a"}}, + NativeBridge: android.NativeBridgeDisabled, NativeBridgeHostArchName: "", NativeBridgeRelativePath: ""}, + {Os: android.Android, Arch: android.Arch{ArchType: android.Arm64, ArchVariant: "armv8-a", Abi: []string{"arm64-v8a"}}, + NativeBridge: android.NativeBridgeEnabled, NativeBridgeHostArchName: "x86_64", NativeBridgeRelativePath: "arm64"}, + {Os: android.Android, Arch: android.Arch{ArchType: android.Arm, ArchVariant: "armv7-a-neon", Abi: []string{"armeabi-v7a"}}, + NativeBridge: android.NativeBridgeEnabled, NativeBridgeHostArchName: "x86", NativeBridgeRelativePath: "arm"}, + } + }, +) + +func withManifestPackageNameOverrides(specs []string) android.FixturePreparer { + return android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { + variables.ManifestPackageNameOverrides = specs + }) } -func withManifestPackageNameOverrides(specs []string) testCustomizer { - return func(fs map[string][]byte, config android.Config) { - config.TestProductVariables.ManifestPackageNameOverrides = specs - } -} +var withBinder32bit = android.FixtureModifyProductVariables( + func(variables android.FixtureProductVariables) { + variables.Binder32bit = proptools.BoolPtr(true) + }, +) -func withBinder32bit(_ map[string][]byte, config android.Config) { - config.TestProductVariables.Binder32bit = proptools.BoolPtr(true) -} - -func withUnbundledBuild(_ map[string][]byte, config android.Config) { - config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true) -} +var withUnbundledBuild = android.FixtureModifyProductVariables( + func(variables android.FixtureProductVariables) { + variables.Unbundled_build = proptools.BoolPtr(true) + }, +) var emptyFixtureFactory = android.NewFixtureFactory(&buildDir)