Move some java test setup later
Move ctx.Register() from testContext() to run() so that tests can register more singletons before the env singleton is registered. Any singletons registered after the env singleton will hit an error if they attempt to read an environment variable. Move setDexpreoptTestGlobalConfig from TestConfig to run() so that a test can set their own custom config after TestConfig but before run(). Test: All Soong tests Change-Id: Iec47f4b7898736f583cbd6bd53e4d02a035f4fb2
This commit is contained in:
parent
baa676f671
commit
c28bb0b8f9
2 changed files with 6 additions and 6 deletions
|
@ -24,6 +24,7 @@ import (
|
|||
|
||||
"android/soong/android"
|
||||
"android/soong/cc"
|
||||
"android/soong/dexpreopt"
|
||||
"android/soong/genrule"
|
||||
)
|
||||
|
||||
|
@ -101,8 +102,6 @@ func testContext(config android.Config, bp string,
|
|||
ctx.BottomUp("begin", cc.BeginMutator).Parallel()
|
||||
})
|
||||
|
||||
ctx.Register()
|
||||
|
||||
bp += GatherRequiredDepsForTest()
|
||||
|
||||
mockFS := map[string][]byte{
|
||||
|
@ -187,6 +186,11 @@ func testContext(config android.Config, bp string,
|
|||
|
||||
func run(t *testing.T, ctx *android.TestContext, config android.Config) {
|
||||
t.Helper()
|
||||
|
||||
pathCtx := android.PathContextForTesting(config, nil)
|
||||
setDexpreoptTestGlobalConfig(config, dexpreopt.GlobalConfigForTests(pathCtx))
|
||||
|
||||
ctx.Register()
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp", "prebuilts/sdk/Android.bp"})
|
||||
android.FailIfErrored(t, errs)
|
||||
_, errs = ctx.PrepareBuildActions(config)
|
||||
|
|
|
@ -18,7 +18,6 @@ import (
|
|||
"fmt"
|
||||
|
||||
"android/soong/android"
|
||||
"android/soong/dexpreopt"
|
||||
)
|
||||
|
||||
func TestConfig(buildDir string, env map[string]string) android.Config {
|
||||
|
@ -31,9 +30,6 @@ func TestConfig(buildDir string, env map[string]string) android.Config {
|
|||
config := android.TestArchConfig(buildDir, env)
|
||||
config.TestProductVariables.DeviceSystemSdkVersions = []string{"14", "15"}
|
||||
|
||||
pathCtx := android.PathContextForTesting(config, nil)
|
||||
setDexpreoptTestGlobalConfig(config, dexpreopt.GlobalConfigForTests(pathCtx))
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue