Test using soong_config_module_type with singleton module type
Singleton module types have some special behavior that can cause problems when trying to extend them with soong_config_module_type so this adds some tests of how they work together. Currently, the tests show that they do not work together, a follow up change will correct that. Bug: 264876909 Test: m nothing Change-Id: I250ee4e18b3c04d1c91808f55722da74b813a570
This commit is contained in:
@@ -15,12 +15,10 @@
|
||||
package android
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type soongConfigTestDefaultsModuleProperties struct {
|
||||
}
|
||||
|
||||
type soongConfigTestDefaultsModule struct {
|
||||
ModuleBase
|
||||
DefaultsModuleBase
|
||||
@@ -413,10 +411,92 @@ func TestDuplicateStringValueInSoongConfigStringVariable(t *testing.T) {
|
||||
})).RunTest(t)
|
||||
}
|
||||
|
||||
func testConfigWithVendorVars(buildDir, bp string, fs map[string][]byte, vendorVars map[string]map[string]string) Config {
|
||||
config := TestConfig(buildDir, nil, bp, fs)
|
||||
|
||||
config.TestProductVariables.VendorVars = vendorVars
|
||||
|
||||
return config
|
||||
type soongConfigTestSingletonModule struct {
|
||||
SingletonModuleBase
|
||||
props soongConfigTestSingletonModuleProperties
|
||||
}
|
||||
|
||||
type soongConfigTestSingletonModuleProperties struct {
|
||||
Fragments []struct {
|
||||
Apex string
|
||||
Module string
|
||||
}
|
||||
}
|
||||
|
||||
func soongConfigTestSingletonModuleFactory() SingletonModule {
|
||||
m := &soongConfigTestSingletonModule{}
|
||||
m.AddProperties(&m.props)
|
||||
InitAndroidModule(m)
|
||||
return m
|
||||
}
|
||||
|
||||
func (t *soongConfigTestSingletonModule) GenerateAndroidBuildActions(ModuleContext) {}
|
||||
|
||||
func (t *soongConfigTestSingletonModule) GenerateSingletonBuildActions(SingletonContext) {}
|
||||
|
||||
var prepareForSoongConfigTestSingletonModule = FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||
ctx.RegisterSingletonModuleType("test_singleton", soongConfigTestSingletonModuleFactory)
|
||||
})
|
||||
|
||||
func TestSoongConfigModuleSingletonModule(t *testing.T) {
|
||||
bp := `
|
||||
soong_config_module_type {
|
||||
name: "acme_test_singleton",
|
||||
module_type: "test_singleton",
|
||||
config_namespace: "acme",
|
||||
bool_variables: ["coyote"],
|
||||
properties: ["fragments"],
|
||||
}
|
||||
|
||||
acme_test_singleton {
|
||||
name: "wiley",
|
||||
fragments: [
|
||||
{
|
||||
apex: "com.android.acme",
|
||||
module: "road-runner",
|
||||
},
|
||||
],
|
||||
soong_config_variables: {
|
||||
coyote: {
|
||||
fragments: [
|
||||
{
|
||||
apex: "com.android.acme",
|
||||
module: "wiley",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
`
|
||||
|
||||
for _, test := range []struct {
|
||||
coyote bool
|
||||
expectedFragments string
|
||||
}{
|
||||
{
|
||||
coyote: false,
|
||||
expectedFragments: "[{Apex:com.android.acme Module:road-runner}]",
|
||||
},
|
||||
{
|
||||
coyote: true,
|
||||
expectedFragments: "[{Apex:com.android.acme Module:road-runner} {Apex:com.android.acme Module:wiley}]",
|
||||
},
|
||||
} {
|
||||
t.Run(fmt.Sprintf("coyote:%t", test.coyote), func(t *testing.T) {
|
||||
GroupFixturePreparers(
|
||||
PrepareForTestWithSoongConfigModuleBuildComponents,
|
||||
prepareForSoongConfigTestSingletonModule,
|
||||
FixtureWithRootAndroidBp(bp),
|
||||
FixtureModifyProductVariables(func(variables FixtureProductVariables) {
|
||||
variables.VendorVars = map[string]map[string]string{
|
||||
"acme": {
|
||||
"coyote": fmt.Sprintf("%t", test.coyote),
|
||||
},
|
||||
}
|
||||
}),
|
||||
).ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern([]string{
|
||||
`\QDuplicate SingletonModule "test_singleton", previously used in\E`,
|
||||
})).RunTest(t)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user