From 535e0a105e9feb84c4f44174beb0dfd8d89b361b Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Tue, 30 Mar 2021 23:34:32 +0100 Subject: [PATCH] Remove unused java testing methods Also, stops exporting methods that are no longer used outside the java package. Bug: 181070625 Test: m nothing Change-Id: I23d35bbc21f82f2dae802aa53badda4c58b41024 --- java/java.go | 4 ++-- java/java_test.go | 17 --------------- java/testing.go | 54 +---------------------------------------------- 3 files changed, 3 insertions(+), 72 deletions(-) diff --git a/java/java.go b/java/java.go index 9786947f7..70ad87938 100644 --- a/java/java.go +++ b/java/java.go @@ -33,12 +33,12 @@ import ( ) func init() { - RegisterJavaBuildComponents(android.InitRegistrationContext) + registerJavaBuildComponents(android.InitRegistrationContext) RegisterJavaSdkMemberTypes() } -func RegisterJavaBuildComponents(ctx android.RegistrationContext) { +func registerJavaBuildComponents(ctx android.RegistrationContext) { ctx.RegisterModuleType("java_defaults", DefaultsFactory) ctx.RegisterModuleType("java_library", LibraryFactory) diff --git a/java/java_test.go b/java/java_test.go index d1d26ba00..158eb8021 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -74,23 +74,6 @@ func testJavaError(t *testing.T, pattern string, bp string) (*android.TestContex return result.TestContext, result.Config } -// testJavaErrorWithConfig is a legacy way of running tests of java modules that expect errors. -// -// See testJava for an explanation as to how to stop using this deprecated method. -// -// deprecated -func testJavaErrorWithConfig(t *testing.T, pattern string, config android.Config) (*android.TestContext, android.Config) { - t.Helper() - // This must be done on the supplied config and not as part of the fixture because any changes to - // the fixture's config will be ignored when RunTestWithConfig replaces it. - pathCtx := android.PathContextForTesting(config) - dexpreopt.SetTestGlobalConfig(config, dexpreopt.GlobalConfigForTests(pathCtx)) - result := prepareForJavaTest. - ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(pattern)). - RunTestWithConfig(t, config) - return result.TestContext, result.Config -} - // testJavaWithFS runs tests using the prepareForJavaTest // // See testJava for an explanation as to how to stop using this deprecated method. diff --git a/java/testing.go b/java/testing.go index 221ceb118..1113af72c 100644 --- a/java/testing.go +++ b/java/testing.go @@ -160,28 +160,6 @@ func FixtureWithPrebuiltApis(release2Modules map[string][]string) android.Fixtur ) } -func TestConfig(buildDir string, env map[string]string, bp string, fs map[string][]byte) android.Config { - bp += GatherRequiredDepsForTest() - - mockFS := android.MockFS{} - - cc.GatherRequiredFilesForTest(mockFS) - - for k, v := range fs { - mockFS[k] = v - } - - if env == nil { - env = make(map[string]string) - } - if env["ANDROID_JAVA8_HOME"] == "" { - env["ANDROID_JAVA8_HOME"] = "jdk8" - } - config := android.TestArchConfig(buildDir, env, bp, mockFS) - - return config -} - func prebuiltApisFilesForLibs(apiLevels []string, sdkLibs []string) map[string][]byte { fs := make(map[string][]byte) for _, level := range apiLevels { @@ -200,19 +178,6 @@ func prebuiltApisFilesForLibs(apiLevels []string, sdkLibs []string) map[string][ return fs } -// Register build components provided by this package that are needed by tests. -// -// In particular this must register all the components that are used in the `Android.bp` snippet -// returned by GatherRequiredDepsForTest() -// -// deprecated: Use test fixtures instead, e.g. PrepareForTestWithJavaBuildComponents -func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) { - registerRequiredBuildComponentsForTest(ctx) - - // Make sure that any tool related module types needed by dexpreopt have been registered. - dexpreopt.RegisterToolModulesForTest(ctx) -} - // registerRequiredBuildComponentsForTest registers the build components used by // PrepareForTestWithJavaDefaultModules. // @@ -228,7 +193,7 @@ func registerRequiredBuildComponentsForTest(ctx android.RegistrationContext) { RegisterDexpreoptBootJarsComponents(ctx) RegisterDocsBuildComponents(ctx) RegisterGenRuleBuildComponents(ctx) - RegisterJavaBuildComponents(ctx) + registerJavaBuildComponents(ctx) RegisterPrebuiltApisBuildComponents(ctx) RegisterRuntimeResourceOverlayBuildComponents(ctx) RegisterSdkLibraryBuildComponents(ctx) @@ -236,23 +201,6 @@ func registerRequiredBuildComponentsForTest(ctx android.RegistrationContext) { RegisterSystemModulesBuildComponents(ctx) } -// Gather the module definitions needed by tests that depend upon code from this package. -// -// Returns an `Android.bp` snippet that defines the modules that are needed by this package. -// -// deprecated: Use test fixtures instead, e.g. PrepareForTestWithJavaDefaultModules -func GatherRequiredDepsForTest() string { - bp := gatherRequiredDepsForTest() - - // For class loader context and tests. - bp += dexpreopt.CompatLibDefinitionsForTest() - - // Make sure that any tools needed for dexpreopting are defined. - bp += dexpreopt.BpToolModulesForTest() - - return bp -} - // gatherRequiredDepsForTest gathers the module definitions used by // PrepareForTestWithJavaDefaultModules. //