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/android/paths_test.go b/android/paths_test.go
index e7fd763..14a4773 100644
--- a/android/paths_test.go
+++ b/android/paths_test.go
@@ -980,12 +980,6 @@
func testPathForModuleSrc(t *testing.T, buildDir string, tests []pathForModuleSrcTestCase) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
- ctx := NewTestContext()
-
- ctx.RegisterModuleType("test", pathForModuleSrcTestModuleFactory)
- ctx.RegisterModuleType("output_file_provider", pathForModuleSrcOutputFileProviderModuleFactory)
- ctx.RegisterModuleType("filegroup", FileGroupFactory)
-
fgBp := `
filegroup {
name: "a",
@@ -1015,7 +1009,13 @@
config := TestConfig(buildDir, nil, "", mockFS)
- ctx.Register(config)
+ ctx := NewTestContext(config)
+
+ ctx.RegisterModuleType("test", pathForModuleSrcTestModuleFactory)
+ ctx.RegisterModuleType("output_file_provider", pathForModuleSrcOutputFileProviderModuleFactory)
+ ctx.RegisterModuleType("filegroup", FileGroupFactory)
+
+ ctx.Register()
_, errs := ctx.ParseFileList(".", []string{"fg/Android.bp", "foo/Android.bp", "ofp/Android.bp"})
FailIfErrored(t, errs)
_, errs = ctx.PrepareBuildActions(config)
@@ -1224,12 +1224,12 @@
config := TestConfig(buildDir, nil, bp, nil)
config.TestProductVariables.Allow_missing_dependencies = proptools.BoolPtr(true)
- ctx := NewTestContext()
+ ctx := NewTestContext(config)
ctx.SetAllowMissingDependencies(true)
ctx.RegisterModuleType("test", pathForModuleSrcTestModuleFactory)
- ctx.Register(config)
+ ctx.Register()
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
FailIfErrored(t, errs)