Add test to reproduce bug in error message.
soong config variable modules allow specifying a non-existent property, which results in an unhelpful error message when the module type is then used. Bug: 171232169 Test: go test soong tests Change-Id: I6174c0d35a28952157ee925f51d615e2ee735f8a
This commit is contained in:
@@ -313,6 +313,51 @@ func TestSoongConfigModule(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestNonExistentPropertyInSoongConfigModule(t *testing.T) {
|
||||
bp := `
|
||||
soong_config_module_type {
|
||||
name: "acme_test",
|
||||
module_type: "test",
|
||||
config_namespace: "acme",
|
||||
bool_variables: ["feature1"],
|
||||
properties: ["made_up_property"],
|
||||
}
|
||||
|
||||
acme_test {
|
||||
name: "foo",
|
||||
cflags: ["-DGENERIC"],
|
||||
soong_config_variables: {
|
||||
feature1: {
|
||||
made_up_property: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
`
|
||||
|
||||
fixtureForVendorVars := func(vars map[string]map[string]string) FixturePreparer {
|
||||
return FixtureModifyProductVariables(func(variables FixtureProductVariables) {
|
||||
variables.VendorVars = vars
|
||||
})
|
||||
}
|
||||
|
||||
GroupFixturePreparers(
|
||||
fixtureForVendorVars(map[string]map[string]string{"acme": {"feature1": "1"}}),
|
||||
PrepareForTestWithDefaults,
|
||||
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||
ctx.RegisterModuleType("soong_config_module_type_import", soongConfigModuleTypeImportFactory)
|
||||
ctx.RegisterModuleType("soong_config_module_type", soongConfigModuleTypeFactory)
|
||||
ctx.RegisterModuleType("soong_config_string_variable", soongConfigStringVariableDummyFactory)
|
||||
ctx.RegisterModuleType("soong_config_bool_variable", soongConfigBoolVariableDummyFactory)
|
||||
ctx.RegisterModuleType("test_defaults", soongConfigTestDefaultsModuleFactory)
|
||||
ctx.RegisterModuleType("test", soongConfigTestModuleFactory)
|
||||
}),
|
||||
FixtureWithRootAndroidBp(bp),
|
||||
).ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern([]string{
|
||||
// TODO(b/171232169): improve the error message for non-existent properties
|
||||
`unrecognized property "soong_config_variables`,
|
||||
})).RunTest(t)
|
||||
}
|
||||
|
||||
func testConfigWithVendorVars(buildDir, bp string, fs map[string][]byte, vendorVars map[string]map[string]string) Config {
|
||||
config := TestConfig(buildDir, nil, bp, fs)
|
||||
|
||||
|
Reference in New Issue
Block a user