Add test to TestJavaStableSdkVersion for legacy core platform

Adds a test case to TestJavaStableSdkVersion for the case where a
module uses sdk_version: "core_platform" but is in the list of modules
that can use the legacy version.

This required storing the lookup map in the Config to allow it to be
customized for the test.

Bug: 180399951
Test: m nothing
Change-Id: I404705c3fd8a559649c6ab2624856cf78f49f85c
This commit is contained in:
Paul Duffin
2021-03-15 09:39:13 +00:00
parent 05732954c6
commit 1ea7c9fa52
4 changed files with 76 additions and 11 deletions

View File

@@ -229,6 +229,26 @@ func FixtureConfigureApexBootJars(bootJars ...string) android.FixturePreparer {
)
}
// FixtureUseLegacyCorePlatformApi prepares the fixture by setting the exception list of those
// modules that are allowed to use the legacy core platform API to be the ones supplied.
func FixtureUseLegacyCorePlatformApi(moduleNames ...string) android.FixturePreparer {
lookup := make(map[string]struct{})
for _, moduleName := range moduleNames {
lookup[moduleName] = struct{}{}
}
return android.FixtureModifyConfig(func(config android.Config) {
// Try and set the legacyCorePlatformApiLookup in the config, the returned value will be the
// actual value that is set.
cached := config.Once(legacyCorePlatformApiLookupKey, func() interface{} {
return lookup
})
// Make sure that the cached value is the one we need.
if !reflect.DeepEqual(cached, lookup) {
panic(fmt.Errorf("attempting to set legacyCorePlatformApiLookupKey to %q but it has already been set to %q", lookup, cached))
}
})
}
// registerRequiredBuildComponentsForTest registers the build components used by
// PrepareForTestWithJavaDefaultModules.
//