Pass Config to NewTestContext instead of ctx.Register
Prepare for using Config when adding singletons by passing
Config to NewTestContext and NewContext instead of to ctx.Register.
This will enable a followup change to store SingletonMakeVarsProviders
registered on the Context in the Config, which is necessary to run
multiple tests in parallel without data races.
Test: all soong tests
Change-Id: Id229629a4e42ff4487d317241673837726c075fc
diff --git a/java/app_test.go b/java/app_test.go
index 82577e3..446050d 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -59,7 +59,7 @@
func testApp(t *testing.T, bp string) *android.TestContext {
config := testAppConfig(nil, bp, nil)
- ctx := testContext()
+ ctx := testContext(config)
run(t, ctx, config)
@@ -220,7 +220,7 @@
config.TestProductVariables.AAPTPrebuiltDPI = test.aaptPrebuiltDPI
config.TestProductVariables.Platform_sdk_version = &test.sdkVersion
config.Targets[android.Android] = test.targets
- ctx := testContext()
+ ctx := testContext(config)
run(t, ctx, config)
module := ctx.ModuleForTests("foo", "android_common")
const packedSplitApks = "foo.zip"
@@ -657,7 +657,7 @@
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
config := testConfig(nil, fmt.Sprintf(bp, testCase.prop), fs)
- ctx := testContext()
+ ctx := testContext(config)
run(t, ctx, config)
module := ctx.ModuleForTests("foo", "android_common")
@@ -973,7 +973,7 @@
config.TestProductVariables.EnforceRROExcludedOverlays = testCase.enforceRROExcludedOverlays
}
- ctx := testContext()
+ ctx := testContext(config)
run(t, ctx, config)
resourceListToFiles := func(module android.TestingModule, list []string) (files []string) {
@@ -1039,7 +1039,7 @@
}
func checkSdkVersion(t *testing.T, config android.Config, expectedSdkVersion string) {
- ctx := testContext()
+ ctx := testContext(config)
run(t, ctx, config)
@@ -1633,7 +1633,7 @@
if test.certificateOverride != "" {
config.TestProductVariables.CertificateOverrides = []string{test.certificateOverride}
}
- ctx := testContext()
+ ctx := testContext(config)
run(t, ctx, config)
foo := ctx.ModuleForTests("foo", "android_common")
@@ -1698,7 +1698,7 @@
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
config := testAppConfig(nil, test.bp, nil)
- ctx := testContext()
+ ctx := testContext(config)
run(t, ctx, config)
foo := ctx.ModuleForTests("foo", "android_common")
@@ -1758,7 +1758,7 @@
if test.packageNameOverride != "" {
config.TestProductVariables.PackageNameOverrides = []string{test.packageNameOverride}
}
- ctx := testContext()
+ ctx := testContext(config)
run(t, ctx, config)
foo := ctx.ModuleForTests("foo", "android_common")
@@ -1793,7 +1793,7 @@
`
config := testAppConfig(nil, bp, nil)
config.TestProductVariables.ManifestPackageNameOverrides = []string{"foo:org.dandroid.bp"}
- ctx := testContext()
+ ctx := testContext(config)
run(t, ctx, config)
@@ -2416,7 +2416,7 @@
config := testAppConfig(nil, bp, nil)
config.TestProductVariables.AAPTPreferredConfig = test.aaptPreferredConfig
config.TestProductVariables.AAPTPrebuiltDPI = test.aaptPrebuiltDPI
- ctx := testContext()
+ ctx := testContext(config)
run(t, ctx, config)
@@ -2777,7 +2777,7 @@
config := testAppConfig(nil, bp, nil)
config.TestProductVariables.MissingUsesLibraries = []string{"baz"}
- ctx := testContext()
+ ctx := testContext(config)
run(t, ctx, config)
@@ -3129,7 +3129,7 @@
config.TestProductVariables.Always_use_prebuilt_sdks = proptools.BoolPtr(true)
}
- ctx := testContext()
+ ctx := testContext(config)
run(t, ctx, config)
@@ -3209,7 +3209,7 @@
}
`
config := testAppConfig(nil, bp, fs)
- ctx := testContext()
+ ctx := testContext(config)
run(t, ctx, config)
m := ctx.ModuleForTests("foo", "android_common")
@@ -3506,7 +3506,7 @@
config.TestProductVariables.EnforceRROExemptedTargets = testCase.enforceRROExemptTargets
}
- ctx := testContext()
+ ctx := testContext(config)
run(t, ctx, config)
modules := []string{"foo", "bar"}