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
This commit is contained in:
@@ -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",
|
||||
|
@@ -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,
|
||||
|
@@ -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",
|
||||
|
@@ -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")
|
||||
|
@@ -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 {
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user