Merge "Pass Config to NewTestContext instead of ctx.Register" am: ceed6be00d
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1480601 Change-Id: Idc791387f2ced40abe768395717fee33e3650e4f
This commit is contained in:
commit
748ecd135f
45 changed files with 209 additions and 208 deletions
|
@ -80,10 +80,10 @@ func TestAndroidMkSingleton_PassesUpdatedAndroidMkDataToCustomCallback(t *testin
|
|||
config := TestConfig(buildDir, nil, bp, nil)
|
||||
config.inMake = true // Enable androidmk Singleton
|
||||
|
||||
ctx := NewTestContext()
|
||||
ctx := NewTestContext(config)
|
||||
ctx.RegisterSingletonType("androidmk", AndroidMkSingleton)
|
||||
ctx.RegisterModuleType("custom", customModuleFactory)
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
FailIfErrored(t, errs)
|
||||
|
@ -252,10 +252,10 @@ func TestGetDistForGoals(t *testing.T) {
|
|||
config := TestConfig(buildDir, nil, testCase.bp, nil)
|
||||
config.inMake = true // Enable androidmk Singleton
|
||||
|
||||
ctx := NewTestContext()
|
||||
ctx := NewTestContext(config)
|
||||
ctx.RegisterSingletonType("androidmk", AndroidMkSingleton)
|
||||
ctx.RegisterModuleType("custom", customModuleFactory)
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
FailIfErrored(t, errs)
|
||||
|
|
|
@ -353,9 +353,9 @@ func TestArchMutator(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
config := TestArchConfig(buildDir, nil, bp, nil)
|
||||
|
||||
ctx := NewTestArchContext()
|
||||
ctx := NewTestArchContext(config)
|
||||
ctx.RegisterModuleType("module", archTestModuleFactory)
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
if tt.config != nil {
|
||||
tt.config(config)
|
||||
}
|
||||
|
@ -442,9 +442,9 @@ func TestArchMutatorNativeBridge(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
config := TestArchConfigNativeBridge(buildDir, nil, bp, nil)
|
||||
|
||||
ctx := NewTestArchContext()
|
||||
ctx := NewTestArchContext(config)
|
||||
ctx.RegisterModuleType("module", archTestModuleFactory)
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
if tt.config != nil {
|
||||
tt.config(config)
|
||||
}
|
||||
|
|
|
@ -21,9 +21,9 @@ import (
|
|||
func testCSuiteConfig(test *testing.T, bpFileContents string) *TestContext {
|
||||
config := TestArchConfig(buildDir, nil, bpFileContents, nil)
|
||||
|
||||
ctx := NewTestArchContext()
|
||||
ctx := NewTestArchContext(config)
|
||||
ctx.RegisterModuleType("csuite_config", CSuiteConfigFactory)
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
FailIfErrored(test, errs)
|
||||
_, errs = ctx.PrepareBuildActions(config)
|
||||
|
|
|
@ -80,14 +80,14 @@ func TestDefaults(t *testing.T) {
|
|||
|
||||
config := TestConfig(buildDir, nil, bp, nil)
|
||||
|
||||
ctx := NewTestContext()
|
||||
ctx := NewTestContext(config)
|
||||
|
||||
ctx.RegisterModuleType("test", defaultsTestModuleFactory)
|
||||
ctx.RegisterModuleType("defaults", defaultsTestDefaultsFactory)
|
||||
|
||||
ctx.PreArchMutators(RegisterDefaultsPreArchMutators)
|
||||
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
FailIfErrored(t, errs)
|
||||
|
@ -125,7 +125,7 @@ func TestDefaultsAllowMissingDependencies(t *testing.T) {
|
|||
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", defaultsTestModuleFactory)
|
||||
|
@ -133,7 +133,7 @@ func TestDefaultsAllowMissingDependencies(t *testing.T) {
|
|||
|
||||
ctx.PreArchMutators(RegisterDefaultsPreArchMutators)
|
||||
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
FailIfErrored(t, errs)
|
||||
|
|
|
@ -164,9 +164,6 @@ func depsModuleFactory() Module {
|
|||
}
|
||||
|
||||
func TestErrorDependsOnDisabledModule(t *testing.T) {
|
||||
ctx := NewTestContext()
|
||||
ctx.RegisterModuleType("deps", depsModuleFactory)
|
||||
|
||||
bp := `
|
||||
deps {
|
||||
name: "foo",
|
||||
|
@ -180,7 +177,9 @@ func TestErrorDependsOnDisabledModule(t *testing.T) {
|
|||
|
||||
config := TestConfig(buildDir, nil, bp, nil)
|
||||
|
||||
ctx.Register(config)
|
||||
ctx := NewTestContext(config)
|
||||
ctx.RegisterModuleType("deps", depsModuleFactory)
|
||||
ctx.Register()
|
||||
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
FailIfErrored(t, errs)
|
||||
|
|
|
@ -70,7 +70,7 @@ func TestMutatorAddMissingDependencies(t *testing.T) {
|
|||
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", mutatorTestModuleFactory)
|
||||
|
@ -78,7 +78,7 @@ func TestMutatorAddMissingDependencies(t *testing.T) {
|
|||
ctx.TopDown("add_missing_dependencies", addMissingDependenciesMutator)
|
||||
})
|
||||
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
FailIfErrored(t, errs)
|
||||
_, errs = ctx.PrepareBuildActions(config)
|
||||
|
@ -92,7 +92,15 @@ func TestMutatorAddMissingDependencies(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestModuleString(t *testing.T) {
|
||||
ctx := NewTestContext()
|
||||
bp := `
|
||||
test {
|
||||
name: "foo",
|
||||
}
|
||||
`
|
||||
|
||||
config := TestConfig(buildDir, nil, bp, nil)
|
||||
|
||||
ctx := NewTestContext(config)
|
||||
|
||||
var moduleStrings []string
|
||||
|
||||
|
@ -130,15 +138,7 @@ func TestModuleString(t *testing.T) {
|
|||
|
||||
ctx.RegisterModuleType("test", mutatorTestModuleFactory)
|
||||
|
||||
bp := `
|
||||
test {
|
||||
name: "foo",
|
||||
}
|
||||
`
|
||||
|
||||
config := TestConfig(buildDir, nil, bp, nil)
|
||||
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
FailIfErrored(t, errs)
|
||||
|
@ -190,7 +190,21 @@ func TestModuleString(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestFinalDepsPhase(t *testing.T) {
|
||||
ctx := NewTestContext()
|
||||
bp := `
|
||||
test {
|
||||
name: "common_dep_1",
|
||||
}
|
||||
test {
|
||||
name: "common_dep_2",
|
||||
}
|
||||
test {
|
||||
name: "foo",
|
||||
}
|
||||
`
|
||||
|
||||
config := TestConfig(buildDir, nil, bp, nil)
|
||||
|
||||
ctx := NewTestContext(config)
|
||||
|
||||
finalGot := map[string]int{}
|
||||
|
||||
|
@ -228,20 +242,7 @@ func TestFinalDepsPhase(t *testing.T) {
|
|||
|
||||
ctx.RegisterModuleType("test", mutatorTestModuleFactory)
|
||||
|
||||
bp := `
|
||||
test {
|
||||
name: "common_dep_1",
|
||||
}
|
||||
test {
|
||||
name: "common_dep_2",
|
||||
}
|
||||
test {
|
||||
name: "foo",
|
||||
}
|
||||
`
|
||||
|
||||
config := TestConfig(buildDir, nil, bp, nil)
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
FailIfErrored(t, errs)
|
||||
|
@ -267,7 +268,8 @@ func TestFinalDepsPhase(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestNoCreateVariationsInFinalDeps(t *testing.T) {
|
||||
ctx := NewTestContext()
|
||||
config := TestConfig(buildDir, nil, `test {name: "foo"}`, nil)
|
||||
ctx := NewTestContext(config)
|
||||
|
||||
checkErr := func() {
|
||||
if err := recover(); err == nil || !strings.Contains(fmt.Sprintf("%s", err), "not allowed in FinalDepsMutators") {
|
||||
|
@ -287,8 +289,7 @@ func TestNoCreateVariationsInFinalDeps(t *testing.T) {
|
|||
})
|
||||
|
||||
ctx.RegisterModuleType("test", mutatorTestModuleFactory)
|
||||
config := TestConfig(buildDir, nil, `test {name: "foo"}`, nil)
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
FailIfErrored(t, errs)
|
||||
|
|
|
@ -635,7 +635,7 @@ func mockFiles(bps map[string]string) (files map[string][]byte) {
|
|||
func setupTestFromFiles(bps map[string][]byte) (ctx *TestContext, errs []error) {
|
||||
config := TestConfig(buildDir, nil, "", bps)
|
||||
|
||||
ctx = NewTestContext()
|
||||
ctx = NewTestContext(config)
|
||||
ctx.RegisterModuleType("test_module", newTestModule)
|
||||
ctx.RegisterModuleType("soong_namespace", NamespaceFactory)
|
||||
ctx.Context.RegisterModuleType("blueprint_test_module", newBlueprintTestModule)
|
||||
|
@ -643,7 +643,7 @@ func setupTestFromFiles(bps map[string][]byte) (ctx *TestContext, errs []error)
|
|||
ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) {
|
||||
ctx.BottomUp("rename", renameMutator)
|
||||
})
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
_, errs = ctx.ParseBlueprintsFiles("Android.bp")
|
||||
if len(errs) > 0 {
|
||||
|
|
|
@ -359,14 +359,14 @@ func TestNeverallow(t *testing.T) {
|
|||
}
|
||||
|
||||
func testNeverallow(config Config) (*TestContext, []error) {
|
||||
ctx := NewTestContext()
|
||||
ctx := NewTestContext(config)
|
||||
ctx.RegisterModuleType("cc_library", newMockCcLibraryModule)
|
||||
ctx.RegisterModuleType("java_library", newMockJavaLibraryModule)
|
||||
ctx.RegisterModuleType("java_library_host", newMockJavaLibraryModule)
|
||||
ctx.RegisterModuleType("java_device_for_host", newMockJavaLibraryModule)
|
||||
ctx.RegisterModuleType("makefile_goal", newMockMakefileGoalModule)
|
||||
ctx.PostDepsMutators(RegisterNeverallowMutator)
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
_, errs := ctx.ParseBlueprintsFiles("Android.bp")
|
||||
if len(errs) > 0 {
|
||||
|
|
|
@ -86,9 +86,9 @@ func testPackage(fs map[string][]byte) (*TestContext, []error) {
|
|||
// Create a new config per test as visibility information is stored in the config.
|
||||
config := TestArchConfig(buildDir, nil, "", fs)
|
||||
|
||||
ctx := NewTestArchContext()
|
||||
ctx := NewTestArchContext(config)
|
||||
RegisterPackageBuildComponents(ctx)
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
_, errs := ctx.ParseBlueprintsFiles(".")
|
||||
if len(errs) > 0 {
|
||||
|
|
|
@ -116,12 +116,12 @@ func TestPathDepsMutator(t *testing.T) {
|
|||
`
|
||||
|
||||
config := TestArchConfig(buildDir, nil, bp, nil)
|
||||
ctx := NewTestArchContext()
|
||||
ctx := NewTestArchContext(config)
|
||||
|
||||
ctx.RegisterModuleType("test", pathDepsMutatorTestModuleFactory)
|
||||
ctx.RegisterModuleType("filegroup", FileGroupFactory)
|
||||
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
FailIfErrored(t, errs)
|
||||
_, errs = ctx.PrepareBuildActions(config)
|
||||
|
|
|
@ -980,12 +980,6 @@ type pathForModuleSrcTestCase struct {
|
|||
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 @@ func testPathForModuleSrc(t *testing.T, buildDir string, tests []pathForModuleSr
|
|||
|
||||
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 @@ func TestPathsForModuleSrc_AllowMissingDependencies(t *testing.T) {
|
|||
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)
|
||||
|
|
|
@ -288,10 +288,10 @@ func TestPrebuilts(t *testing.T) {
|
|||
{Windows, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", "", true},
|
||||
}
|
||||
|
||||
ctx := NewTestArchContext()
|
||||
ctx := NewTestArchContext(config)
|
||||
registerTestPrebuiltBuildComponents(ctx)
|
||||
ctx.RegisterModuleType("filegroup", FileGroupFactory)
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
_, errs := ctx.ParseBlueprintsFiles("Android.bp")
|
||||
FailIfErrored(t, errs)
|
||||
|
|
|
@ -81,10 +81,11 @@ func RegisterPreSingletonType(name string, factory SingletonFactory) {
|
|||
|
||||
type Context struct {
|
||||
*blueprint.Context
|
||||
config Config
|
||||
}
|
||||
|
||||
func NewContext() *Context {
|
||||
ctx := &Context{blueprint.NewContext()}
|
||||
func NewContext(config Config) *Context {
|
||||
ctx := &Context{blueprint.NewContext(), config}
|
||||
ctx.SetSrcDir(absSrcDir)
|
||||
return ctx
|
||||
}
|
||||
|
@ -157,7 +158,7 @@ type RegistrationContext interface {
|
|||
// Extracting the actual registration into a separate RegisterBuildComponents(ctx) function
|
||||
// allows it to be used to initialize test context, e.g.
|
||||
//
|
||||
// ctx := android.NewTestContext()
|
||||
// ctx := android.NewTestContext(config)
|
||||
// RegisterBuildComponents(ctx)
|
||||
var InitRegistrationContext RegistrationContext = &initRegistrationContext{
|
||||
moduleTypes: make(map[string]ModuleFactory),
|
||||
|
|
|
@ -507,10 +507,10 @@ func TestRuleBuilder_Build(t *testing.T) {
|
|||
`
|
||||
|
||||
config := TestConfig(buildDir, nil, bp, fs)
|
||||
ctx := NewTestContext()
|
||||
ctx := NewTestContext(config)
|
||||
ctx.RegisterModuleType("rule_builder_test", testRuleBuilderFactory)
|
||||
ctx.RegisterSingletonType("rule_builder_test", testRuleBuilderSingletonFactory)
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
FailIfErrored(t, errs)
|
||||
|
|
|
@ -175,7 +175,7 @@ func TestSoongConfigModule(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
ctx := NewTestContext()
|
||||
ctx := NewTestContext(config)
|
||||
ctx.RegisterModuleType("soong_config_module_type_import", soongConfigModuleTypeImportFactory)
|
||||
ctx.RegisterModuleType("soong_config_module_type", soongConfigModuleTypeFactory)
|
||||
ctx.RegisterModuleType("soong_config_string_variable", soongConfigStringVariableDummyFactory)
|
||||
|
@ -183,7 +183,7 @@ func TestSoongConfigModule(t *testing.T) {
|
|||
ctx.RegisterModuleType("test_defaults", soongConfigTestDefaultsModuleFactory)
|
||||
ctx.RegisterModuleType("test", soongConfigTestModuleFactory)
|
||||
ctx.PreArchMutators(RegisterDefaultsPreArchMutators)
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
_, errs := ctx.ParseBlueprintsFiles("Android.bp")
|
||||
FailIfErrored(t, errs)
|
||||
|
|
|
@ -25,14 +25,14 @@ import (
|
|||
"github.com/google/blueprint"
|
||||
)
|
||||
|
||||
func NewTestContext() *TestContext {
|
||||
func NewTestContext(config Config) *TestContext {
|
||||
namespaceExportFilter := func(namespace *Namespace) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
nameResolver := NewNameResolver(namespaceExportFilter)
|
||||
ctx := &TestContext{
|
||||
Context: &Context{blueprint.NewContext()},
|
||||
Context: &Context{blueprint.NewContext(), config},
|
||||
NameResolver: nameResolver,
|
||||
}
|
||||
|
||||
|
@ -40,11 +40,16 @@ func NewTestContext() *TestContext {
|
|||
|
||||
ctx.postDeps = append(ctx.postDeps, registerPathDepsMutator)
|
||||
|
||||
ctx.SetFs(ctx.config.fs)
|
||||
if ctx.config.mockBpList != "" {
|
||||
ctx.SetModuleListFile(ctx.config.mockBpList)
|
||||
}
|
||||
|
||||
return ctx
|
||||
}
|
||||
|
||||
func NewTestArchContext() *TestContext {
|
||||
ctx := NewTestContext()
|
||||
func NewTestArchContext(config Config) *TestContext {
|
||||
ctx := NewTestContext(config)
|
||||
ctx.preDeps = append(ctx.preDeps, registerArchMutator)
|
||||
return ctx
|
||||
}
|
||||
|
@ -53,7 +58,6 @@ type TestContext struct {
|
|||
*Context
|
||||
preArch, preDeps, postDeps, finalDeps []RegisterMutatorFunc
|
||||
NameResolver *NameResolver
|
||||
config Config
|
||||
}
|
||||
|
||||
func (ctx *TestContext) PreArchMutators(f RegisterMutatorFunc) {
|
||||
|
@ -77,16 +81,10 @@ func (ctx *TestContext) FinalDepsMutators(f RegisterMutatorFunc) {
|
|||
ctx.finalDeps = append(ctx.finalDeps, f)
|
||||
}
|
||||
|
||||
func (ctx *TestContext) Register(config Config) {
|
||||
ctx.SetFs(config.fs)
|
||||
if config.mockBpList != "" {
|
||||
ctx.SetModuleListFile(config.mockBpList)
|
||||
}
|
||||
func (ctx *TestContext) Register() {
|
||||
registerMutators(ctx.Context.Context, ctx.preArch, ctx.preDeps, ctx.postDeps, ctx.finalDeps)
|
||||
|
||||
ctx.RegisterSingletonType("env", EnvSingleton)
|
||||
|
||||
ctx.config = config
|
||||
}
|
||||
|
||||
func (ctx *TestContext) ParseFileList(rootDir string, filePaths []string) (deps []string, errs []error) {
|
||||
|
|
|
@ -157,23 +157,6 @@ func testProductVariableModuleFactoryFactory(props interface{}) func() Module {
|
|||
}
|
||||
|
||||
func TestProductVariables(t *testing.T) {
|
||||
ctx := NewTestContext()
|
||||
// A module type that has a srcs property but not a cflags property.
|
||||
ctx.RegisterModuleType("module1", testProductVariableModuleFactoryFactory(&struct {
|
||||
Srcs []string
|
||||
}{}))
|
||||
// A module type that has a cflags property but not a srcs property.
|
||||
ctx.RegisterModuleType("module2", testProductVariableModuleFactoryFactory(&struct {
|
||||
Cflags []string
|
||||
}{}))
|
||||
// A module type that does not have any properties that match product_variables.
|
||||
ctx.RegisterModuleType("module3", testProductVariableModuleFactoryFactory(&struct {
|
||||
Foo []string
|
||||
}{}))
|
||||
ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) {
|
||||
ctx.BottomUp("variable", VariableMutator).Parallel()
|
||||
})
|
||||
|
||||
// Test that a module can use one product variable even if it doesn't have all the properties
|
||||
// supported by that product variable.
|
||||
bp := `
|
||||
|
@ -201,7 +184,24 @@ func TestProductVariables(t *testing.T) {
|
|||
config := TestConfig(buildDir, nil, bp, nil)
|
||||
config.TestProductVariables.Eng = proptools.BoolPtr(true)
|
||||
|
||||
ctx.Register(config)
|
||||
ctx := NewTestContext(config)
|
||||
// A module type that has a srcs property but not a cflags property.
|
||||
ctx.RegisterModuleType("module1", testProductVariableModuleFactoryFactory(&struct {
|
||||
Srcs []string
|
||||
}{}))
|
||||
// A module type that has a cflags property but not a srcs property.
|
||||
ctx.RegisterModuleType("module2", testProductVariableModuleFactoryFactory(&struct {
|
||||
Cflags []string
|
||||
}{}))
|
||||
// A module type that does not have any properties that match product_variables.
|
||||
ctx.RegisterModuleType("module3", testProductVariableModuleFactoryFactory(&struct {
|
||||
Foo []string
|
||||
}{}))
|
||||
ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) {
|
||||
ctx.BottomUp("variable", VariableMutator).Parallel()
|
||||
})
|
||||
|
||||
ctx.Register()
|
||||
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
FailIfErrored(t, errs)
|
||||
|
@ -293,7 +293,7 @@ func TestProductVariablesDefaults(t *testing.T) {
|
|||
config := TestConfig(buildDir, nil, bp, nil)
|
||||
config.TestProductVariables.Eng = boolPtr(true)
|
||||
|
||||
ctx := NewTestContext()
|
||||
ctx := NewTestContext(config)
|
||||
|
||||
ctx.RegisterModuleType("test", productVariablesDefaultsTestModuleFactory)
|
||||
ctx.RegisterModuleType("defaults", productVariablesDefaultsTestDefaultsFactory)
|
||||
|
@ -303,7 +303,7 @@ func TestProductVariablesDefaults(t *testing.T) {
|
|||
ctx.BottomUp("variable", VariableMutator).Parallel()
|
||||
})
|
||||
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
FailIfErrored(t, errs)
|
||||
|
|
|
@ -1168,7 +1168,7 @@ func testVisibility(buildDir string, fs map[string][]byte) (*TestContext, []erro
|
|||
// Create a new config per test as visibility information is stored in the config.
|
||||
config := TestArchConfig(buildDir, nil, "", fs)
|
||||
|
||||
ctx := NewTestArchContext()
|
||||
ctx := NewTestArchContext(config)
|
||||
ctx.RegisterModuleType("mock_library", newMockLibraryModule)
|
||||
ctx.RegisterModuleType("mock_parent", newMockParentFactory)
|
||||
ctx.RegisterModuleType("mock_defaults", defaultsFactory)
|
||||
|
@ -1180,7 +1180,7 @@ func testVisibility(buildDir string, fs map[string][]byte) (*TestContext, []erro
|
|||
ctx.PreArchMutators(RegisterDefaultsPreArchMutators)
|
||||
ctx.PreArchMutators(RegisterVisibilityRuleGatherer)
|
||||
ctx.PostDepsMutators(RegisterVisibilityRuleEnforcer)
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
_, errs := ctx.ParseBlueprintsFiles(".")
|
||||
if len(errs) > 0 {
|
||||
|
|
|
@ -216,7 +216,7 @@ func testApexContext(_ *testing.T, bp string, handlers ...testCustomizer) (*andr
|
|||
handler(tempFS, config)
|
||||
}
|
||||
|
||||
ctx := android.NewTestArchContext()
|
||||
ctx := android.NewTestArchContext(config)
|
||||
|
||||
// from android package
|
||||
android.RegisterPackageBuildComponents(ctx)
|
||||
|
@ -261,7 +261,7 @@ func testApexContext(_ *testing.T, bp string, handlers ...testCustomizer) (*andr
|
|||
ctx.PreDepsMutators(RegisterPreDepsMutators)
|
||||
ctx.PostDepsMutators(RegisterPostDepsMutators)
|
||||
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
return ctx, config
|
||||
}
|
||||
|
@ -5746,7 +5746,9 @@ func testNoUpdatableJarsInBootImage(t *testing.T, errmsg string, transformDexpre
|
|||
}
|
||||
cc.GatherRequiredFilesForTest(fs)
|
||||
|
||||
ctx := android.NewTestArchContext()
|
||||
config := android.TestArchConfig(buildDir, nil, bp, fs)
|
||||
|
||||
ctx := android.NewTestArchContext(config)
|
||||
ctx.RegisterModuleType("apex", BundleFactory)
|
||||
ctx.RegisterModuleType("apex_key", ApexKeyFactory)
|
||||
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
|
||||
|
@ -5761,8 +5763,7 @@ func testNoUpdatableJarsInBootImage(t *testing.T, errmsg string, transformDexpre
|
|||
ctx.PreDepsMutators(RegisterPreDepsMutators)
|
||||
ctx.PostDepsMutators(RegisterPostDepsMutators)
|
||||
|
||||
config := android.TestArchConfig(buildDir, nil, bp, fs)
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
_ = dexpreopt.GlobalSoongConfigForTests(config)
|
||||
dexpreopt.RegisterToolModulesForTest(ctx)
|
||||
|
@ -5897,7 +5898,15 @@ func testApexPermittedPackagesRules(t *testing.T, errmsg, bp string, apexBootJar
|
|||
"system/sepolicy/apex/myapex-file_contexts": nil,
|
||||
}
|
||||
|
||||
ctx := android.NewTestArchContext()
|
||||
config := android.TestArchConfig(buildDir, nil, bp, fs)
|
||||
android.SetTestNeverallowRules(config, rules)
|
||||
updatableBootJars := make([]string, 0, len(apexBootJars))
|
||||
for _, apexBootJar := range apexBootJars {
|
||||
updatableBootJars = append(updatableBootJars, "myapex:"+apexBootJar)
|
||||
}
|
||||
config.TestProductVariables.UpdatableBootJars = android.CreateTestConfiguredJarList(updatableBootJars)
|
||||
|
||||
ctx := android.NewTestArchContext(config)
|
||||
ctx.RegisterModuleType("apex", BundleFactory)
|
||||
ctx.RegisterModuleType("apex_key", ApexKeyFactory)
|
||||
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
||||
|
@ -5910,15 +5919,7 @@ func testApexPermittedPackagesRules(t *testing.T, errmsg, bp string, apexBootJar
|
|||
ctx.PostDepsMutators(RegisterPostDepsMutators)
|
||||
ctx.PostDepsMutators(android.RegisterNeverallowMutator)
|
||||
|
||||
config := android.TestArchConfig(buildDir, nil, bp, fs)
|
||||
android.SetTestNeverallowRules(config, rules)
|
||||
updatableBootJars := make([]string, 0, len(apexBootJars))
|
||||
for _, apexBootJar := range apexBootJars {
|
||||
updatableBootJars = append(updatableBootJars, "myapex:"+apexBootJar)
|
||||
}
|
||||
config.TestProductVariables.UpdatableBootJars = android.CreateTestConfiguredJarList(updatableBootJars)
|
||||
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
_, errs := ctx.ParseBlueprintsFiles("Android.bp")
|
||||
android.FailIfErrored(t, errs)
|
||||
|
|
|
@ -58,9 +58,9 @@ func testConfig(buildDir string, env map[string]string, bp string) android.Confi
|
|||
}
|
||||
|
||||
func testContext(config android.Config) *android.TestContext {
|
||||
ctx := cc.CreateTestContext()
|
||||
ctx := cc.CreateTestContext(config)
|
||||
ctx.RegisterModuleType("bpf", BpfFactory)
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
return ctx
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -22,9 +22,9 @@ import (
|
|||
)
|
||||
|
||||
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
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
|
||||
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 @@ func testPrebuilt(t *testing.T, bp string, fs map[string][]byte, handlers ...con
|
|||
handler(config)
|
||||
}
|
||||
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
android.FailIfErrored(t, errs)
|
||||
_, errs = ctx.PrepareBuildActions(config)
|
||||
|
|
|
@ -122,10 +122,10 @@ func TestDataTests(t *testing.T) {
|
|||
"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)
|
||||
|
|
|
@ -545,8 +545,8 @@ func TestConfig(buildDir string, os android.OsType, env map[string]string,
|
|||
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)
|
||||
|
|
|
@ -52,7 +52,7 @@ func newNameResolver(config android.Config) *android.NameResolver {
|
|||
}
|
||||
|
||||
func newContext(srcDir string, configuration android.Config) *android.Context {
|
||||
ctx := android.NewContext()
|
||||
ctx := android.NewContext(configuration)
|
||||
ctx.Register()
|
||||
if !shouldPrepareBuildActions() {
|
||||
configuration.SetStopBefore(bootstrap.StopBeforePrepareBuildActions)
|
||||
|
|
|
@ -234,9 +234,9 @@ func TestGenerateBazelQueryViewFromBlueprint(t *testing.T) {
|
|||
|
||||
for _, testCase := range testCases {
|
||||
config := android.TestConfig(buildDir, nil, testCase.bp, nil)
|
||||
ctx := android.NewTestContext()
|
||||
ctx := android.NewTestContext(config)
|
||||
ctx.RegisterModuleType("custom", customModuleFactory)
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
android.FailIfErrored(t, errs)
|
||||
|
|
|
@ -58,7 +58,7 @@ func testPrebuiltEtcContext(t *testing.T, bp string) (*android.TestContext, andr
|
|||
|
||||
config := android.TestArchConfig(buildDir, nil, bp, fs)
|
||||
|
||||
ctx := android.NewTestArchContext()
|
||||
ctx := android.NewTestArchContext(config)
|
||||
ctx.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
|
||||
ctx.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory)
|
||||
ctx.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
|
||||
|
@ -66,7 +66,7 @@ func testPrebuiltEtcContext(t *testing.T, bp string) (*android.TestContext, andr
|
|||
ctx.RegisterModuleType("prebuilt_font", PrebuiltFontFactory)
|
||||
ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
|
||||
ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory)
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
return ctx, config
|
||||
}
|
||||
|
|
|
@ -53,14 +53,14 @@ func TestMain(m *testing.M) {
|
|||
|
||||
func testContext(config android.Config) *android.TestContext {
|
||||
|
||||
ctx := android.NewTestArchContext()
|
||||
ctx := android.NewTestArchContext(config)
|
||||
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
|
||||
ctx.RegisterModuleType("tool", toolFactory)
|
||||
|
||||
registerGenruleBuildComponents(ctx)
|
||||
|
||||
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
return ctx
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
|
||||
func init() {
|
||||
android.RegisterPreSingletonType("overlay", OverlaySingletonFactory)
|
||||
|
||||
}
|
||||
|
||||
var androidResourceIgnoreFilenames = []string{
|
||||
|
|
|
@ -59,7 +59,7 @@ func testAppConfig(env map[string]string, bp string, fs map[string][]byte) andro
|
|||
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 @@ func TestAndroidAppSet_Variants(t *testing.T) {
|
|||
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 @@ func TestResourceDirs(t *testing.T) {
|
|||
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 @@ func TestAndroidResources(t *testing.T) {
|
|||
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 TestAndroidResources(t *testing.T) {
|
|||
}
|
||||
|
||||
func checkSdkVersion(t *testing.T, config android.Config, expectedSdkVersion string) {
|
||||
ctx := testContext()
|
||||
ctx := testContext(config)
|
||||
|
||||
run(t, ctx, config)
|
||||
|
||||
|
@ -1633,7 +1633,7 @@ func TestCertificates(t *testing.T) {
|
|||
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 @@ func TestRequestV4SigningFlag(t *testing.T) {
|
|||
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 @@ func TestPackageNameOverride(t *testing.T) {
|
|||
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 @@ func TestInstrumentationTargetOverridden(t *testing.T) {
|
|||
`
|
||||
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 @@ func TestAndroidAppImport_DpiVariants(t *testing.T) {
|
|||
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 @@ func TestUsesLibraries(t *testing.T) {
|
|||
config := testAppConfig(nil, bp, nil)
|
||||
config.TestProductVariables.MissingUsesLibraries = []string{"baz"}
|
||||
|
||||
ctx := testContext()
|
||||
ctx := testContext(config)
|
||||
|
||||
run(t, ctx, config)
|
||||
|
||||
|
@ -3129,7 +3129,7 @@ func TestUncompressDex(t *testing.T) {
|
|||
config.TestProductVariables.Always_use_prebuilt_sdks = proptools.BoolPtr(true)
|
||||
}
|
||||
|
||||
ctx := testContext()
|
||||
ctx := testContext(config)
|
||||
|
||||
run(t, ctx, config)
|
||||
|
||||
|
@ -3209,7 +3209,7 @@ func TestRuntimeResourceOverlay(t *testing.T) {
|
|||
}
|
||||
`
|
||||
config := testAppConfig(nil, bp, fs)
|
||||
ctx := testContext()
|
||||
ctx := testContext(config)
|
||||
run(t, ctx, config)
|
||||
|
||||
m := ctx.ModuleForTests("foo", "android_common")
|
||||
|
@ -3506,7 +3506,7 @@ func TestEnforceRRO_propagatesToDependencies(t *testing.T) {
|
|||
config.TestProductVariables.EnforceRROExemptedTargets = testCase.enforceRROExemptTargets
|
||||
}
|
||||
|
||||
ctx := testContext()
|
||||
ctx := testContext(config)
|
||||
run(t, ctx, config)
|
||||
|
||||
modules := []string{"foo", "bar"}
|
||||
|
|
|
@ -51,7 +51,7 @@ func testDexpreoptBoot(t *testing.T, ruleFile string, expectedInputs, expectedOu
|
|||
dexpreoptConfig.BootJars = android.CreateTestConfiguredJarList([]string{"platform:foo", "platform:bar", "platform:baz"})
|
||||
dexpreopt.SetTestGlobalConfig(config, dexpreoptConfig)
|
||||
|
||||
ctx := testContext()
|
||||
ctx := testContext(config)
|
||||
RegisterDexpreoptBootJarsComponents(ctx)
|
||||
run(t, ctx, config)
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ func testConfigWithBootJars(bp string, bootJars []string) android.Config {
|
|||
return config
|
||||
}
|
||||
|
||||
func testContextWithHiddenAPI() *android.TestContext {
|
||||
ctx := testContext()
|
||||
func testContextWithHiddenAPI(config android.Config) *android.TestContext {
|
||||
ctx := testContext(config)
|
||||
ctx.RegisterSingletonType("hiddenapi", hiddenAPISingletonFactory)
|
||||
return ctx
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ func testContextWithHiddenAPI() *android.TestContext {
|
|||
func testHiddenAPIWithConfig(t *testing.T, config android.Config) *android.TestContext {
|
||||
t.Helper()
|
||||
|
||||
ctx := testContextWithHiddenAPI()
|
||||
ctx := testContextWithHiddenAPI(config)
|
||||
|
||||
run(t, ctx, config)
|
||||
return ctx
|
||||
|
|
|
@ -70,9 +70,9 @@ func testConfig(env map[string]string, bp string, fs map[string][]byte) android.
|
|||
return config
|
||||
}
|
||||
|
||||
func testContext() *android.TestContext {
|
||||
func testContext(config android.Config) *android.TestContext {
|
||||
|
||||
ctx := android.NewTestArchContext()
|
||||
ctx := android.NewTestArchContext(config)
|
||||
RegisterJavaBuildComponents(ctx)
|
||||
RegisterAppBuildComponents(ctx)
|
||||
RegisterAARBuildComponents(ctx)
|
||||
|
@ -115,7 +115,7 @@ func run(t *testing.T, ctx *android.TestContext, config android.Config) {
|
|||
pathCtx := android.PathContextForTesting(config)
|
||||
dexpreopt.SetTestGlobalConfig(config, dexpreopt.GlobalConfigForTests(pathCtx))
|
||||
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
_, errs := ctx.ParseBlueprintsFiles("Android.bp")
|
||||
android.FailIfErrored(t, errs)
|
||||
_, errs = ctx.PrepareBuildActions(config)
|
||||
|
@ -129,12 +129,12 @@ func testJavaError(t *testing.T, pattern string, bp string) (*android.TestContex
|
|||
|
||||
func testJavaErrorWithConfig(t *testing.T, pattern string, config android.Config) (*android.TestContext, android.Config) {
|
||||
t.Helper()
|
||||
ctx := testContext()
|
||||
ctx := testContext(config)
|
||||
|
||||
pathCtx := android.PathContextForTesting(config)
|
||||
dexpreopt.SetTestGlobalConfig(config, dexpreopt.GlobalConfigForTests(pathCtx))
|
||||
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
_, errs := ctx.ParseBlueprintsFiles("Android.bp")
|
||||
if len(errs) > 0 {
|
||||
android.FailIfNoMatchingErrors(t, pattern, errs)
|
||||
|
@ -163,7 +163,7 @@ func testJava(t *testing.T, bp string) (*android.TestContext, android.Config) {
|
|||
|
||||
func testJavaWithConfig(t *testing.T, config android.Config) (*android.TestContext, android.Config) {
|
||||
t.Helper()
|
||||
ctx := testContext()
|
||||
ctx := testContext(config)
|
||||
run(t, ctx, config)
|
||||
|
||||
return ctx, config
|
||||
|
@ -1440,7 +1440,7 @@ func TestJavaLibrary(t *testing.T) {
|
|||
}
|
||||
`),
|
||||
})
|
||||
ctx := testContext()
|
||||
ctx := testContext(config)
|
||||
run(t, ctx, config)
|
||||
}
|
||||
|
||||
|
@ -1458,7 +1458,7 @@ func TestJavaImport(t *testing.T) {
|
|||
}
|
||||
`),
|
||||
})
|
||||
ctx := testContext()
|
||||
ctx := testContext(config)
|
||||
run(t, ctx, config)
|
||||
}
|
||||
|
||||
|
|
|
@ -356,7 +356,7 @@ func TestClasspath(t *testing.T) {
|
|||
config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
|
||||
config.TestProductVariables.Always_use_prebuilt_sdks = proptools.BoolPtr(true)
|
||||
}
|
||||
ctx := testContext()
|
||||
ctx := testContext(config)
|
||||
run(t, ctx, config)
|
||||
|
||||
checkClasspath(t, ctx, true /* isJava8 */)
|
||||
|
@ -377,7 +377,7 @@ func TestClasspath(t *testing.T) {
|
|||
config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
|
||||
config.TestProductVariables.Always_use_prebuilt_sdks = proptools.BoolPtr(true)
|
||||
}
|
||||
ctx := testContext()
|
||||
ctx := testContext(config)
|
||||
run(t, ctx, config)
|
||||
|
||||
checkClasspath(t, ctx, false /* isJava8 */)
|
||||
|
@ -401,7 +401,7 @@ func TestClasspath(t *testing.T) {
|
|||
config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
|
||||
config.TestProductVariables.Always_use_prebuilt_sdks = proptools.BoolPtr(true)
|
||||
}
|
||||
ctx := testContext()
|
||||
ctx := testContext(config)
|
||||
run(t, ctx, config)
|
||||
|
||||
checkClasspath(t, ctx, true /* isJava8 */)
|
||||
|
@ -417,7 +417,7 @@ func TestClasspath(t *testing.T) {
|
|||
config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
|
||||
config.TestProductVariables.Always_use_prebuilt_sdks = proptools.BoolPtr(true)
|
||||
}
|
||||
ctx := testContext()
|
||||
ctx := testContext(config)
|
||||
run(t, ctx, config)
|
||||
|
||||
checkClasspath(t, ctx, false /* isJava8 */)
|
||||
|
|
|
@ -56,9 +56,9 @@ func testContext(t *testing.T, bp string) (*android.TestContext, android.Config)
|
|||
|
||||
config := android.TestArchConfig(buildDir, nil, bp, fs)
|
||||
|
||||
ctx := android.NewTestArchContext()
|
||||
ctx := android.NewTestArchContext(config)
|
||||
ctx.RegisterModuleType("linker_config", linkerConfigFactory)
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
android.FailIfErrored(t, errs)
|
||||
|
|
|
@ -329,13 +329,13 @@ func TestPythonModule(t *testing.T) {
|
|||
for _, d := range data {
|
||||
t.Run(d.desc, func(t *testing.T) {
|
||||
config := android.TestConfig(buildDir, nil, "", d.mockFiles)
|
||||
ctx := android.NewTestContext()
|
||||
ctx := android.NewTestContext(config)
|
||||
ctx.PreDepsMutators(RegisterPythonPreDepsMutators)
|
||||
ctx.RegisterModuleType("python_library_host", PythonLibraryHostFactory)
|
||||
ctx.RegisterModuleType("python_binary_host", PythonBinaryHostFactory)
|
||||
ctx.RegisterModuleType("python_defaults", defaultsFactory)
|
||||
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
_, testErrs := ctx.ParseBlueprintsFiles(bpFile)
|
||||
android.FailIfErrored(t, testErrs)
|
||||
_, actErrs := ctx.PrepareBuildActions(config)
|
||||
|
|
|
@ -65,8 +65,8 @@ func TestClippy(t *testing.T) {
|
|||
t.Run("path="+tc.modulePath, func(t *testing.T) {
|
||||
|
||||
config := android.TestArchConfig(buildDir, nil, bp, fs)
|
||||
ctx := CreateTestContext()
|
||||
ctx.Register(config)
|
||||
ctx := CreateTestContext(config)
|
||||
ctx.Register()
|
||||
_, errs := ctx.ParseFileList(".", []string{tc.modulePath + "Android.bp"})
|
||||
android.FailIfErrored(t, errs)
|
||||
_, errs = ctx.PrepareBuildActions(config)
|
||||
|
|
|
@ -152,8 +152,8 @@ func TestLints(t *testing.T) {
|
|||
t.Run("path="+tc.modulePath, func(t *testing.T) {
|
||||
|
||||
config := android.TestArchConfig(buildDir, nil, bp, fs)
|
||||
ctx := CreateTestContext()
|
||||
ctx.Register(config)
|
||||
ctx := CreateTestContext(config)
|
||||
ctx.Register()
|
||||
_, errs := ctx.ParseFileList(".", []string{tc.modulePath + "Android.bp"})
|
||||
android.FailIfErrored(t, errs)
|
||||
_, errs = ctx.PrepareBuildActions(config)
|
||||
|
|
|
@ -142,8 +142,8 @@ func (tctx testRustCtx) parse(t *testing.T) *android.TestContext {
|
|||
if tctx.config == nil {
|
||||
t.Fatalf("tctx.config not been generated yet. Please call generateConfig first.")
|
||||
}
|
||||
ctx := CreateTestContext()
|
||||
ctx.Register(*tctx.config)
|
||||
ctx := CreateTestContext(*tctx.config)
|
||||
ctx.Register()
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
android.FailIfErrored(t, errs)
|
||||
_, errs = ctx.PrepareBuildActions(*tctx.config)
|
||||
|
@ -157,8 +157,8 @@ func (tctx testRustCtx) parseError(t *testing.T, pattern string) {
|
|||
if tctx.config == nil {
|
||||
t.Fatalf("tctx.config not been generated yet. Please call generateConfig first.")
|
||||
}
|
||||
ctx := CreateTestContext()
|
||||
ctx.Register(*tctx.config)
|
||||
ctx := CreateTestContext(*tctx.config)
|
||||
ctx.Register()
|
||||
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
if len(errs) > 0 {
|
||||
|
|
|
@ -127,8 +127,8 @@ func GatherRequiredDepsForTest() string {
|
|||
return bp
|
||||
}
|
||||
|
||||
func CreateTestContext() *android.TestContext {
|
||||
ctx := android.NewTestArchContext()
|
||||
func CreateTestContext(config android.Config) *android.TestContext {
|
||||
ctx := android.NewTestArchContext(config)
|
||||
android.RegisterPrebuiltMutators(ctx)
|
||||
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
||||
cc.RegisterRequiredBuildComponentsForTest(ctx)
|
||||
|
|
|
@ -80,7 +80,7 @@ func testSdkContext(bp string, fs map[string][]byte, extraOsTypes []android.OsTy
|
|||
}
|
||||
}
|
||||
|
||||
ctx := android.NewTestArchContext()
|
||||
ctx := android.NewTestArchContext(config)
|
||||
|
||||
// Enable androidmk support.
|
||||
// * Register the singleton
|
||||
|
@ -129,7 +129,7 @@ func testSdkContext(bp string, fs map[string][]byte, extraOsTypes []android.OsTy
|
|||
ctx.PreDepsMutators(RegisterPreDepsMutators)
|
||||
ctx.PostDepsMutators(RegisterPostDepsMutators)
|
||||
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
return ctx, config
|
||||
}
|
||||
|
|
|
@ -45,13 +45,13 @@ func testShBinary(t *testing.T, bp string) (*android.TestContext, android.Config
|
|||
|
||||
config := android.TestArchConfig(buildDir, nil, bp, fs)
|
||||
|
||||
ctx := android.NewTestArchContext()
|
||||
ctx := android.NewTestArchContext(config)
|
||||
ctx.RegisterModuleType("sh_test", ShTestFactory)
|
||||
ctx.RegisterModuleType("sh_test_host", ShTestHostFactory)
|
||||
|
||||
cc.RegisterRequiredBuildComponentsForTest(ctx)
|
||||
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
android.FailIfErrored(t, errs)
|
||||
_, errs = ctx.PrepareBuildActions(config)
|
||||
|
|
|
@ -57,7 +57,7 @@ func TestMain(m *testing.M) {
|
|||
|
||||
func testContext(config android.Config) *android.TestContext {
|
||||
|
||||
ctx := android.NewTestArchContext()
|
||||
ctx := android.NewTestArchContext(config)
|
||||
java.RegisterJavaBuildComponents(ctx)
|
||||
java.RegisterAppBuildComponents(ctx)
|
||||
java.RegisterSystemModulesBuildComponents(ctx)
|
||||
|
@ -76,7 +76,7 @@ func testContext(config android.Config) *android.TestContext {
|
|||
|
||||
ctx.RegisterModuleType("sysprop_library", syspropLibraryFactory)
|
||||
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
|
||||
return ctx
|
||||
}
|
||||
|
|
|
@ -57,10 +57,10 @@ func testXml(t *testing.T, bp string) *android.TestContext {
|
|||
"baz.xml": nil,
|
||||
}
|
||||
config := android.TestArchConfig(buildDir, nil, bp, fs)
|
||||
ctx := android.NewTestArchContext()
|
||||
ctx := android.NewTestArchContext(config)
|
||||
ctx.RegisterModuleType("prebuilt_etc", etc.PrebuiltEtcFactory)
|
||||
ctx.RegisterModuleType("prebuilt_etc_xml", PrebuiltEtcXmlFactory)
|
||||
ctx.Register(config)
|
||||
ctx.Register()
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
android.FailIfErrored(t, errs)
|
||||
_, errs = ctx.PrepareBuildActions(config)
|
||||
|
|
Loading…
Reference in a new issue