Make dexpreopt tools available for all java tests

Bug: 177892522
Test: m nothing
Change-Id: I594bddae692ef76dc8c3da504934d0151b13d4c9
This commit is contained in:
Paul Duffin
2021-01-25 19:11:24 +00:00
parent f17b07fc52
commit 635aa0834f
4 changed files with 7 additions and 7 deletions

View File

@@ -5925,7 +5925,6 @@ func testDexpreoptWithApexes(t *testing.T, bp, errmsg string, transformDexpreopt
bp += cc.GatherRequiredDepsForTest(android.Android) bp += cc.GatherRequiredDepsForTest(android.Android)
bp += java.GatherRequiredDepsForTest() bp += java.GatherRequiredDepsForTest()
bp += dexpreopt.BpToolModulesForTest()
fs := map[string][]byte{ fs := map[string][]byte{
"a.java": nil, "a.java": nil,
@@ -5957,7 +5956,6 @@ func testDexpreoptWithApexes(t *testing.T, bp, errmsg string, transformDexpreopt
ctx.Register() ctx.Register()
dexpreopt.RegisterToolModulesForTest(ctx)
pathCtx := android.PathContextForTesting(config) pathCtx := android.PathContextForTesting(config)
dexpreoptConfig := dexpreopt.GlobalConfigForTests(pathCtx) dexpreoptConfig := dexpreopt.GlobalConfigForTests(pathCtx)
transformDexpreoptConfig(dexpreoptConfig) transformDexpreoptConfig(dexpreoptConfig)

View File

@@ -34,7 +34,7 @@ func dummyToolBinaryFactory() android.Module {
return module return module
} }
func RegisterToolModulesForTest(ctx *android.TestContext) { func RegisterToolModulesForTest(ctx android.RegistrationContext) {
ctx.RegisterModuleType("dummy_tool_binary", dummyToolBinaryFactory) ctx.RegisterModuleType("dummy_tool_binary", dummyToolBinaryFactory)
} }

View File

@@ -59,8 +59,6 @@ func TestMain(m *testing.M) {
} }
func testConfig(env map[string]string, bp string, fs map[string][]byte) android.Config { func testConfig(env map[string]string, bp string, fs map[string][]byte) android.Config {
bp += dexpreopt.BpToolModulesForTest()
return TestConfig(buildDir, env, bp, fs) return TestConfig(buildDir, env, bp, fs)
} }
@@ -84,8 +82,6 @@ func testContext(config android.Config) *android.TestContext {
// Register module types and mutators from cc needed for JNI testing // Register module types and mutators from cc needed for JNI testing
cc.RegisterRequiredBuildComponentsForTest(ctx) cc.RegisterRequiredBuildComponentsForTest(ctx)
dexpreopt.RegisterToolModulesForTest(ctx)
ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) { ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.TopDown("propagate_rro_enforcement", propagateRROEnforcementMutator).Parallel() ctx.TopDown("propagate_rro_enforcement", propagateRROEnforcementMutator).Parallel()
}) })

View File

@@ -113,6 +113,9 @@ func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
RegisterSdkLibraryBuildComponents(ctx) RegisterSdkLibraryBuildComponents(ctx)
RegisterStubsBuildComponents(ctx) RegisterStubsBuildComponents(ctx)
RegisterSystemModulesBuildComponents(ctx) RegisterSystemModulesBuildComponents(ctx)
// Make sure that any tool related module types needed by dexpreopt have been registered.
dexpreopt.RegisterToolModulesForTest(ctx)
} }
// Gather the module definitions needed by tests that depend upon code from this package. // Gather the module definitions needed by tests that depend upon code from this package.
@@ -204,6 +207,9 @@ func GatherRequiredDepsForTest() string {
`, extra) `, extra)
} }
// Make sure that any tools needed for dexpreopting are defined.
bp += dexpreopt.BpToolModulesForTest()
// Make sure that the dex_bootjars singleton module is instantiated for the tests. // Make sure that the dex_bootjars singleton module is instantiated for the tests.
bp += ` bp += `
dex_bootjars { dex_bootjars {