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/cc/cc_test.go b/cc/cc_test.go
index b3bb282..b803cba 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -53,8 +53,8 @@
func testCcWithConfig(t *testing.T, config android.Config) *android.TestContext {
t.Helper()
- ctx := CreateTestContext()
- ctx.Register(config)
+ ctx := CreateTestContext(config)
+ ctx.Register()
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
android.FailIfErrored(t, errs)
@@ -84,8 +84,8 @@
func testCcErrorWithConfig(t *testing.T, pattern string, config android.Config) {
t.Helper()
- ctx := CreateTestContext()
- ctx.Register(config)
+ ctx := CreateTestContext(config)
+ ctx.Register()
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
if len(errs) > 0 {
@@ -1293,8 +1293,8 @@
config := TestConfig(buildDir, android.Android, nil, "", mockFS)
config.TestProductVariables.DeviceVndkVersion = StringPtr("BOARD")
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
- ctx := CreateTestContext()
- ctx.Register(config)
+ ctx := CreateTestContext(config)
+ ctx.Register()
_, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp", "vendor/Android.bp", "vndk/Android.bp"})
android.FailIfErrored(t, errs)
@@ -1451,8 +1451,8 @@
config := TestConfig(buildDir, android.Android, nil, "", mockFS)
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
- ctx := CreateTestContext()
- ctx.Register(config)
+ ctx := CreateTestContext(config)
+ ctx.Register()
_, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp", "device/Android.bp"})
android.FailIfErrored(t, errs)
@@ -1541,8 +1541,8 @@
config := TestConfig(buildDir, android.Android, nil, "", mockFS)
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
- ctx := CreateTestContext()
- ctx.Register(config)
+ ctx := CreateTestContext(config)
+ ctx.Register()
_, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "device/Android.bp"})
android.FailIfErrored(t, errs)
@@ -1582,8 +1582,8 @@
config := TestConfig(buildDir, android.Android, nil, "", mockFS)
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
- ctx := CreateTestContext()
- ctx.Register(config)
+ ctx := CreateTestContext(config)
+ ctx.Register()
_, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp"})
android.FailIfErrored(t, errs)
@@ -3882,11 +3882,11 @@
config := TestConfig(buildDir, android.Android, nil, bp, nil)
config.TestProductVariables.Debuggable = BoolPtr(true)
- ctx := CreateTestContext()
+ ctx := CreateTestContext(config)
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("variable", android.VariableMutator).Parallel()
})
- ctx.Register(config)
+ ctx.Register()
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
android.FailIfErrored(t, errs)
@@ -3917,9 +3917,9 @@
config := TestConfig(buildDir, android.Android, nil, bp, nil)
config.TestProductVariables.Allow_missing_dependencies = BoolPtr(true)
- ctx := CreateTestContext()
+ ctx := CreateTestContext(config)
ctx.SetAllowMissingDependencies(true)
- ctx.Register(config)
+ ctx.Register()
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
android.FailIfErrored(t, errs)
diff --git a/cc/genrule_test.go b/cc/genrule_test.go
index a366f76..0c7952b 100644
--- a/cc/genrule_test.go
+++ b/cc/genrule_test.go
@@ -22,9 +22,9 @@
)
func testGenruleContext(config android.Config) *android.TestContext {
- ctx := android.NewTestArchContext()
+ ctx := android.NewTestArchContext(config)
ctx.RegisterModuleType("cc_genrule", genRuleFactory)
- ctx.Register(config)
+ ctx.Register()
return ctx
}
diff --git a/cc/prebuilt_test.go b/cc/prebuilt_test.go
index 1f070a5..5bf334e 100644
--- a/cc/prebuilt_test.go
+++ b/cc/prebuilt_test.go
@@ -25,7 +25,7 @@
func testPrebuilt(t *testing.T, bp string, fs map[string][]byte, handlers ...configCustomizer) *android.TestContext {
config := TestConfig(buildDir, android.Android, nil, bp, fs)
- ctx := CreateTestContext()
+ ctx := CreateTestContext(config)
// Enable androidmk support.
// * Register the singleton
@@ -38,7 +38,7 @@
handler(config)
}
- ctx.Register(config)
+ ctx.Register()
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
android.FailIfErrored(t, errs)
_, errs = ctx.PrepareBuildActions(config)
diff --git a/cc/test_data_test.go b/cc/test_data_test.go
index ae59e2f..426dfc5 100644
--- a/cc/test_data_test.go
+++ b/cc/test_data_test.go
@@ -122,10 +122,10 @@
"dir/baz": nil,
"dir/bar/baz": nil,
})
- ctx := android.NewTestContext()
+ ctx := android.NewTestContext(config)
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
ctx.RegisterModuleType("test", newTest)
- ctx.Register(config)
+ ctx.Register()
_, errs := ctx.ParseBlueprintsFiles("Blueprints")
android.FailIfErrored(t, errs)
diff --git a/cc/testing.go b/cc/testing.go
index 388a9ce..5a311f4 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -545,8 +545,8 @@
return config
}
-func CreateTestContext() *android.TestContext {
- ctx := android.NewTestArchContext()
+func CreateTestContext(config android.Config) *android.TestContext {
+ ctx := android.NewTestArchContext(config)
ctx.RegisterModuleType("cc_fuzz", FuzzFactory)
ctx.RegisterModuleType("cc_test", TestFactory)
ctx.RegisterModuleType("cc_test_library", TestLibraryFactory)