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
This commit is contained in:
Colin Cross
2020-10-29 17:09:13 -07:00
parent 45e0c95f85
commit ae8600b507
45 changed files with 209 additions and 208 deletions

View File

@@ -53,8 +53,8 @@ func TestMain(m *testing.M) {
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 testCcNoVndk(t *testing.T, bp string) *android.TestContext {
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 @@ func TestVendorSnapshotUse(t *testing.T) {
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 @@ func TestVendorSnapshotExclude(t *testing.T) {
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 @@ func TestVendorSnapshotExcludeInVendorProprietaryPathErrors(t *testing.T) {
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 @@ func TestVendorSnapshotExcludeWithVendorAvailable(t *testing.T) {
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 @@ func TestProductVariableDefaults(t *testing.T) {
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 @@ func TestEmptyWholeStaticLibsAllowMissingDependencies(t *testing.T) {
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)