From a66b4630f60847c216699831b99aeb905362ccda Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 8 Aug 2024 15:50:47 -0700 Subject: [PATCH] Add PrepareForTestWithBuildFlag Add a helper function that creates a test fixture preparer that sets a build flag, and use it everywhere that was setting build flags manually. Test: all soong tests Flag: EXEMPT refactor Change-Id: I68d50d68787a30d091f0827e8caa51f5c5a762ef --- android/config_test.go | 7 +--- android/prebuilt_test.go | 6 +--- android/testing.go | 10 ++++++ apex/apex_test.go | 18 ++-------- apex/bootclasspath_fragment_test.go | 12 ++----- apex/dexpreopt_bootjars_test.go | 6 +--- apex/platform_bootclasspath_test.go | 17 +++------ cc/cc_test.go | 7 +--- cc/prebuilt_test.go | 18 ++-------- java/bootclasspath_fragment_test.go | 6 +--- java/droidstubs_test.go | 4 +-- java/hiddenapi_singleton_test.go | 4 +-- java/java_test.go | 12 ++----- java/sdk_library_test.go | 50 +++++--------------------- java/system_modules_test.go | 6 +--- sdk/bootclasspath_fragment_sdk_test.go | 18 ++-------- sdk/java_sdk_test.go | 18 ++-------- sdk/sdk_test.go | 10 ++---- 18 files changed, 49 insertions(+), 180 deletions(-) diff --git a/android/config_test.go b/android/config_test.go index ca7c7f8b4..773216844 100644 --- a/android/config_test.go +++ b/android/config_test.go @@ -150,12 +150,7 @@ func TestReleaseAconfigExtraReleaseConfigs(t *testing.T) { for _, tc := range testCases { fixture := GroupFixturePreparers( - FixtureModifyProductVariables(func(vars FixtureProductVariables) { - if vars.BuildFlags == nil { - vars.BuildFlags = make(map[string]string) - } - vars.BuildFlags["RELEASE_ACONFIG_EXTRA_RELEASE_CONFIGS"] = tc.flag - }), + PrepareForTestWithBuildFlag("RELEASE_ACONFIG_EXTRA_RELEASE_CONFIGS", tc.flag), ) actual := fixture.RunTest(t).Config.ReleaseAconfigExtraReleaseConfigs() AssertArrayString(t, tc.name, tc.expected, actual) diff --git a/android/prebuilt_test.go b/android/prebuilt_test.go index 6e4fc0c2f..5e4af0ba5 100644 --- a/android/prebuilt_test.go +++ b/android/prebuilt_test.go @@ -574,11 +574,7 @@ func newOverrideSourceModule() Module { func TestPrebuiltErrorCannotListBothSourceAndPrebuiltInContributions(t *testing.T) { selectMainlineModuleContritbutions := GroupFixturePreparers( - FixtureModifyProductVariables(func(variables FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "my_apex_contributions", - } - }), + PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", "my_apex_contributions"), ) testPrebuiltErrorWithFixture(t, `Found duplicate variations of the same module in apex_contributions: foo and prebuilt_foo. Please remove one of these`, ` source { diff --git a/android/testing.go b/android/testing.go index dae787b7f..e3853b844 100644 --- a/android/testing.go +++ b/android/testing.go @@ -174,6 +174,16 @@ var PrepareForTestDisallowNonExistentPaths = FixtureModifyConfig(func(config Con config.TestAllowNonExistentPaths = false }) +// PrepareForTestWithBuildFlag returns a FixturePreparer that sets the given flag to the given value. +func PrepareForTestWithBuildFlag(flag, value string) FixturePreparer { + return FixtureModifyProductVariables(func(variables FixtureProductVariables) { + if variables.BuildFlags == nil { + variables.BuildFlags = make(map[string]string) + } + variables.BuildFlags[flag] = value + }) +} + func NewTestArchContext(config Config) *TestContext { ctx := NewTestContext(config) ctx.preDeps = append(ctx.preDeps, registerArchMutator) diff --git a/apex/apex_test.go b/apex/apex_test.go index 852f5fbd7..d6c8a8a73 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -11299,11 +11299,7 @@ func TestBootDexJarsMultipleApexPrebuilts(t *testing.T) { fs["platform/Test.java"] = nil }), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": tc.selectedApexContributions, - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", tc.selectedApexContributions), ) ctx := testDexpreoptWithApexes(t, bp, "", preparer, fragment) checkBootDexJarPath(t, ctx, "framework-foo", tc.expectedBootJar) @@ -11442,11 +11438,7 @@ func TestInstallationRulesForMultipleApexPrebuilts(t *testing.T) { android.FixtureMergeMockFs(map[string][]byte{ "system/sepolicy/apex/com.android.foo-file_contexts": nil, }), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": tc.selectedApexContributions, - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", tc.selectedApexContributions), ) if tc.expectedError != "" { preparer = preparer.ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern(tc.expectedError)) @@ -11562,11 +11554,7 @@ func TestInstallationRulesForMultipleApexPrebuiltsWithoutSource(t *testing.T) { android.FixtureMergeMockFs(map[string][]byte{ "system/sepolicy/apex/com.android.adservices-file_contexts": nil, }), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": tc.selectedApexContributions, - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", tc.selectedApexContributions), ) ctx := testApex(t, bp, preparer) diff --git a/apex/bootclasspath_fragment_test.go b/apex/bootclasspath_fragment_test.go index 533f937af..f8c823e94 100644 --- a/apex/bootclasspath_fragment_test.go +++ b/apex/bootclasspath_fragment_test.go @@ -53,11 +53,7 @@ func TestBootclasspathFragments_FragmentDependency(t *testing.T) { java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz"), java.FixtureConfigureApexBootJars("someapex:foo", "someapex:bar"), prepareForTestWithArtApex, - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"), java.PrepareForTestWithJavaSdkLibraryFiles, java.FixtureWithLastReleaseApis("foo", "baz"), ).RunTestWithBp(t, ` @@ -731,11 +727,7 @@ func TestBootclasspathFragment_HiddenAPIList(t *testing.T) { java.PrepareForTestWithJavaSdkLibraryFiles, java.FixtureWithLastReleaseApis("foo", "quuz"), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"), ).RunTestWithBp(t, ` apex { name: "com.android.art", diff --git a/apex/dexpreopt_bootjars_test.go b/apex/dexpreopt_bootjars_test.go index 7a17f501c..95db37d0a 100644 --- a/apex/dexpreopt_bootjars_test.go +++ b/apex/dexpreopt_bootjars_test.go @@ -399,11 +399,7 @@ func TestDexpreoptProfileWithMultiplePrebuiltArtApexes(t *testing.T) { java.FixtureConfigureBootJars("com.android.art:core-oj"), PrepareForTestWithApexBuildComponents, prepareForTestWithArtApex, - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_APEX_CONTRIBUTIONS_ART": tc.selectedArtApexContributions, - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ART", tc.selectedArtApexContributions), ).RunTestWithBp(t, bp) dexBootJars := result.ModuleForTests("dex_bootjars", "android_common") diff --git a/apex/platform_bootclasspath_test.go b/apex/platform_bootclasspath_test.go index 4a20cf0e3..645eebb13 100644 --- a/apex/platform_bootclasspath_test.go +++ b/apex/platform_bootclasspath_test.go @@ -254,11 +254,7 @@ func TestPlatformBootclasspathDependencies(t *testing.T) { java.FixtureWithLastReleaseApis("foo"), java.PrepareForTestWithDexpreopt, dexpreopt.FixtureDisableDexpreoptBootImages(false), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"), ).RunTestWithBp(t, ` apex { name: "com.android.art", @@ -429,10 +425,9 @@ func TestPlatformBootclasspath_AlwaysUsePrebuiltSdks(t *testing.T) { java.PrepareForTestWithJavaSdkLibraryFiles, android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { variables.Always_use_prebuilt_sdks = proptools.BoolPtr(true) - variables.BuildFlags = map[string]string{ - "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", - } }), + android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"), + java.FixtureWithPrebuiltApis(map[string][]string{ "current": {}, "30": {"foo"}, @@ -935,11 +930,7 @@ func TestNonBootJarMissingInPrebuiltFragment(t *testing.T) { PrepareForTestWithApexBuildComponents, prepareForTestWithMyapex, java.FixtureConfigureApexBootJars(tc.configuredBootJars...), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_APEX_CONTRIBUTIONS_ART": "my_apex_contributions", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ART", "my_apex_contributions"), ) if tc.errorExpected { fixture = fixture.ExtendWithErrorHandler( diff --git a/cc/cc_test.go b/cc/cc_test.go index b1c094547..7372fff66 100644 --- a/cc/cc_test.go +++ b/cc/cc_test.go @@ -3194,12 +3194,7 @@ func TestVendorSdkVersion(t *testing.T) { ctx = android.GroupFixturePreparers( prepareForCcTest, - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - if variables.BuildFlags == nil { - variables.BuildFlags = make(map[string]string) - } - variables.BuildFlags["RELEASE_BOARD_API_LEVEL_FROZEN"] = "true" - }), + android.PrepareForTestWithBuildFlag("RELEASE_BOARD_API_LEVEL_FROZEN", "true"), ).RunTestWithBp(t, bp) testSdkVersionFlag("libfoo", "30") testSdkVersionFlag("libbar", "29") diff --git a/cc/prebuilt_test.go b/cc/prebuilt_test.go index 86e6af96a..acbbabc06 100644 --- a/cc/prebuilt_test.go +++ b/cc/prebuilt_test.go @@ -476,11 +476,7 @@ func TestMultiplePrebuilts(t *testing.T) { android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) { android.RegisterApexContributionsBuildComponents(ctx) }), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "myapex_contributions", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", "myapex_contributions"), ) ctx := testPrebuilt(t, fmt.Sprintf(bp, tc.selectedDependencyName), map[string][]byte{ "libbar.so": nil, @@ -574,11 +570,7 @@ func TestMultiplePrebuiltsPreferredUsingLegacyFlags(t *testing.T) { android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) { android.RegisterApexContributionsBuildComponents(ctx) }), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "myapex_contributions", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", "myapex_contributions"), ) if tc.expectedErr != "" { preparer = preparer.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(tc.expectedErr)) @@ -638,11 +630,7 @@ func TestMissingVariantInModuleSdk(t *testing.T) { android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) { android.RegisterApexContributionsBuildComponents(ctx) }), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "myapex_contributions", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", "myapex_contributions"), ) ctx := testPrebuilt(t, bp, map[string][]byte{ "libbar.so": nil, diff --git a/java/bootclasspath_fragment_test.go b/java/bootclasspath_fragment_test.go index 8bc0a7ef6..d72417afa 100644 --- a/java/bootclasspath_fragment_test.go +++ b/java/bootclasspath_fragment_test.go @@ -222,11 +222,7 @@ func TestBootclasspathFragment_StubLibs(t *testing.T) { PrepareForTestWithJavaSdkLibraryFiles, FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary", "mycoreplatform"), FixtureConfigureApexBootJars("someapex:mysdklibrary"), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"), ).RunTestWithBp(t, ` bootclasspath_fragment { name: "myfragment", diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go index 6a14f3645..1e8362cf2 100644 --- a/java/droidstubs_test.go +++ b/java/droidstubs_test.go @@ -421,11 +421,9 @@ func TestReleaseExportRuntimeApis(t *testing.T) { result := android.GroupFixturePreparers( prepareForJavaTest, android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", - } variables.ExportRuntimeApis = proptools.BoolPtr(true) }), + android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"), android.FixtureMergeMockFs(map[string][]byte{ "a/A.java": nil, "a/current.txt": nil, diff --git a/java/hiddenapi_singleton_test.go b/java/hiddenapi_singleton_test.go index 62297978c..afe8b4c8e 100644 --- a/java/hiddenapi_singleton_test.go +++ b/java/hiddenapi_singleton_test.go @@ -203,10 +203,8 @@ func TestHiddenAPISingletonSdks(t *testing.T) { FixtureConfigureBootJars("platform:foo"), android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { variables.Always_use_prebuilt_sdks = proptools.BoolPtr(tc.unbundledBuild) - variables.BuildFlags = map[string]string{ - "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", - } }), + android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"), ).RunTestWithBp(t, ` java_library { name: "foo", diff --git a/java/java_test.go b/java/java_test.go index 2d4fca240..86bfe9fe4 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -2634,11 +2634,7 @@ func TestMultiplePrebuilts(t *testing.T) { for _, tc := range testCases { ctx := android.GroupFixturePreparers( prepareForJavaTest, - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "myapex_contributions", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", "myapex_contributions"), ).RunTestWithBp(t, fmt.Sprintf(bp, tc.selectedDependencyName)) // check that rdep gets the correct variation of dep @@ -2708,11 +2704,7 @@ func TestMultiplePlatformCompatConfigPrebuilts(t *testing.T) { ctx := android.GroupFixturePreparers( prepareForJavaTest, PrepareForTestWithPlatformCompatConfig, - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "myapex_contributions", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", "myapex_contributions"), ).RunTestWithBp(t, fmt.Sprintf(bp, tc.selectedDependencyName)) mergedGlobalConfig := ctx.SingletonForTests("platform_compat_config_singleton").Output("compat_config/merged_compat_config.xml") diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go index 911e8b1e4..368eca7f2 100644 --- a/java/sdk_library_test.go +++ b/java/sdk_library_test.go @@ -35,11 +35,7 @@ func TestJavaSdkLibrary(t *testing.T) { "29": {"foo"}, "30": {"bar", "barney", "baz", "betty", "foo", "fred", "quuz", "wilma"}, }), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"), ).RunTestWithBp(t, ` droiddoc_exported_dir { name: "droiddoc-templates-sdk", @@ -537,11 +533,7 @@ func TestJavaSdkLibrary_Deps(t *testing.T) { prepareForJavaTest, PrepareForTestWithJavaSdkLibraryFiles, FixtureWithLastReleaseApis("sdklib"), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"), ).RunTestWithBp(t, ` java_sdk_library { name: "sdklib", @@ -934,11 +926,7 @@ func TestJavaSdkLibraryImport_WithSource(t *testing.T) { prepareForJavaTest, PrepareForTestWithJavaSdkLibraryFiles, FixtureWithLastReleaseApis("sdklib"), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"), ).RunTestWithBp(t, ` java_sdk_library { name: "sdklib", @@ -987,11 +975,7 @@ func testJavaSdkLibraryImport_Preferred(t *testing.T, prefer string, preparer an PrepareForTestWithJavaSdkLibraryFiles, FixtureWithLastReleaseApis("sdklib"), preparer, - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"), ).RunTestWithBp(t, ` java_sdk_library { name: "sdklib", @@ -1183,11 +1167,7 @@ func TestSdkLibraryImport_MetadataModuleSupersedesPreferred(t *testing.T) { prepareForJavaTest, PrepareForTestWithJavaSdkLibraryFiles, FixtureWithLastReleaseApis("sdklib.source_preferred_using_legacy_flags", "sdklib.prebuilt_preferred_using_legacy_flags"), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "my_mainline_module_contributions", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", "my_mainline_module_contributions"), ).RunTestWithBp(t, bp) // Make sure that rdeps get the correct source vs prebuilt based on mainline_module_contributions @@ -1369,11 +1349,7 @@ func TestJavaSdkLibraryDist(t *testing.T) { "sdklib_group_foo", "sdklib_owner_foo", "foo"), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"), ).RunTestWithBp(t, ` java_sdk_library { name: "sdklib_no_group", @@ -1785,12 +1761,8 @@ func TestStubResolutionOfJavaSdkLibraryInLibs(t *testing.T) { prepareForJavaTest, PrepareForTestWithJavaSdkLibraryFiles, FixtureWithLastReleaseApis("sdklib"), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - // We can use any of the apex contribution build flags from build/soong/android/config.go#mainlineApexContributionBuildFlags here - "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "my_mainline_module_contributions", - } - }), + // We can use any of the apex contribution build flags from build/soong/android/config.go#mainlineApexContributionBuildFlags here + android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", "my_mainline_module_contributions"), ) result := fixture.RunTestWithBp(t, bp) @@ -1873,11 +1845,7 @@ func TestMultipleSdkLibraryPrebuilts(t *testing.T) { prepareForJavaTest, PrepareForTestWithJavaSdkLibraryFiles, FixtureWithLastReleaseApis("sdklib", "sdklib.v1", "sdklib.v2"), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "my_mainline_module_contributions", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", "my_mainline_module_contributions"), ) for _, tc := range testCases { diff --git a/java/system_modules_test.go b/java/system_modules_test.go index 336dd2134..1a8d0b5d5 100644 --- a/java/system_modules_test.go +++ b/java/system_modules_test.go @@ -182,11 +182,7 @@ func TestMultipleSystemModulesPrebuilts(t *testing.T) { for _, tc := range testCases { res := android.GroupFixturePreparers( prepareForJavaTest, - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "myapex_contributions", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", "myapex_contributions"), ).RunTestWithBp(t, fmt.Sprintf(bp, tc.selectedDependencyName)) // check that rdep gets the correct variation of system_modules diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go index 7048a15b7..7ee548f34 100644 --- a/sdk/bootclasspath_fragment_sdk_test.go +++ b/sdk/bootclasspath_fragment_sdk_test.go @@ -276,11 +276,7 @@ func testSnapshotWithBootClasspathFragment_Contents(t *testing.T, sdk string, co // Add a platform_bootclasspath that depends on the fragment. fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"), // Make sure that we have atleast one platform library so that we can check the monolithic hiddenapi // file creation. java.FixtureConfigureBootJars("platform:foo"), @@ -799,11 +795,7 @@ func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) { // Add a platform_bootclasspath that depends on the fragment. fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"), android.MockFS{ "my-blocked.txt": nil, @@ -1053,11 +1045,7 @@ func testSnapshotWithBootClasspathFragment_MinSdkVersion(t *testing.T, targetBui variables.Platform_version_active_codenames = []string{"VanillaIceCream"} }), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"), android.FixtureWithRootAndroidBp(` sdk { diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go index 0a5483b07..0fb5c70d2 100644 --- a/sdk/java_sdk_test.go +++ b/sdk/java_sdk_test.go @@ -45,11 +45,7 @@ var prepareForSdkTestWithJavaSdkLibrary = android.GroupFixturePreparers( java.PrepareForTestWithJavaDefaultModules, java.PrepareForTestWithJavaSdkLibraryFiles, java.FixtureWithLastReleaseApis("myjavalib"), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"), ) // Contains tests for SDK members provided by the java package. @@ -666,11 +662,7 @@ func TestSnapshotWithJavaSystemModules(t *testing.T) { "1": {"myjavalib"}, "2": {"myjavalib"}, }), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"), ).RunTestWithBp(t, ` sdk { name: "mysdk", @@ -1313,11 +1305,7 @@ java_sdk_library_import { func TestSnapshotWithJavaSdkLibrary_CompileDex(t *testing.T) { result := android.GroupFixturePreparers( prepareForSdkTestWithJavaSdkLibrary, - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"), ).RunTestWithBp(t, ` sdk { name: "mysdk", diff --git a/sdk/sdk_test.go b/sdk/sdk_test.go index 4894210d4..057b370d3 100644 --- a/sdk/sdk_test.go +++ b/sdk/sdk_test.go @@ -457,11 +457,7 @@ java_import { android.FixtureMergeEnv(map[string]string{ "SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": "S", }), - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", - } - }), + android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"), ).RunTest(t) CheckSnapshot(t, result, "mysdk", "", @@ -573,11 +569,9 @@ java_sdk_library_import { "SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": "S", }), android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", - } variables.Platform_version_active_codenames = []string{"UpsideDownCake", "Tiramisu", "S-V2"} }), + android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"), ).RunTest(t) CheckSnapshot(t, result, "mysdk", "",