Update selects_test for selects with deferred expressions
Bug: 323382414 Test: m nothing --no-skip-soong-tests Change-Id: I18257ff586fb31d4e0b012a249726a925832cdac
This commit is contained in:
@@ -97,6 +97,26 @@ func TestSelects(t *testing.T) {
|
||||
my_paths: &[]string{"baz.txt"},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Expression in select",
|
||||
bp: `
|
||||
my_module_type {
|
||||
name: "foo",
|
||||
my_string: select(soong_config_variable("my_namespace", "my_variable"), {
|
||||
"a": "foo" + "bar",
|
||||
default: "baz",
|
||||
}),
|
||||
}
|
||||
`,
|
||||
provider: selectsTestProvider{
|
||||
my_string: proptools.StringPtr("foobar"),
|
||||
},
|
||||
vendorVars: map[string]map[string]string{
|
||||
"my_namespace": {
|
||||
"my_variable": "a",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "paths with module references",
|
||||
bp: `
|
||||
@@ -111,20 +131,6 @@ func TestSelects(t *testing.T) {
|
||||
`,
|
||||
expectedError: `"foo" depends on undefined module "c"`,
|
||||
},
|
||||
{
|
||||
name: "Differing types",
|
||||
bp: `
|
||||
my_module_type {
|
||||
name: "foo",
|
||||
my_string: select(soong_config_variable("my_namespace", "my_variable"), {
|
||||
"a": "a.cpp",
|
||||
"b": true,
|
||||
default: "c.cpp",
|
||||
}),
|
||||
}
|
||||
`,
|
||||
expectedError: `Android.bp:8:5: Found select statement with differing types "string" and "bool" in its cases`,
|
||||
},
|
||||
{
|
||||
name: "Select type doesn't match property type",
|
||||
bp: `
|
||||
@@ -137,7 +143,7 @@ func TestSelects(t *testing.T) {
|
||||
}),
|
||||
}
|
||||
`,
|
||||
expectedError: `can't assign bool value to string property "my_string\[0\]"`,
|
||||
expectedError: `can't assign bool value to string property`,
|
||||
},
|
||||
{
|
||||
name: "String list non-default",
|
||||
@@ -825,6 +831,24 @@ func TestSelects(t *testing.T) {
|
||||
my_string_list: &[]string{"a.cpp", "c.cpp", "foo.cpp"},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Arch variant bool",
|
||||
bp: `
|
||||
my_variable = ["b.cpp"]
|
||||
my_module_type {
|
||||
name: "foo",
|
||||
arch_variant_configurable_bool: false,
|
||||
target: {
|
||||
bionic_arm64: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
`,
|
||||
provider: selectsTestProvider{
|
||||
arch_variant_configurable_bool: proptools.BoolPtr(false),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
@@ -873,6 +897,7 @@ type selectsTestProvider struct {
|
||||
my_string_list *[]string
|
||||
my_paths *[]string
|
||||
replacing_string_list *[]string
|
||||
arch_variant_configurable_bool *bool
|
||||
my_nonconfigurable_bool *bool
|
||||
my_nonconfigurable_string *string
|
||||
my_nonconfigurable_string_list []string
|
||||
@@ -897,6 +922,7 @@ func (p *selectsTestProvider) String() string {
|
||||
my_string_list: %s,
|
||||
my_paths: %s,
|
||||
replacing_string_list %s,
|
||||
arch_variant_configurable_bool %v
|
||||
my_nonconfigurable_bool: %v,
|
||||
my_nonconfigurable_string: %s,
|
||||
my_nonconfigurable_string_list: %s,
|
||||
@@ -906,6 +932,7 @@ func (p *selectsTestProvider) String() string {
|
||||
p.my_string_list,
|
||||
p.my_paths,
|
||||
p.replacing_string_list,
|
||||
p.arch_variant_configurable_bool,
|
||||
p.my_nonconfigurable_bool,
|
||||
myNonconfigurableStringStr,
|
||||
p.my_nonconfigurable_string_list,
|
||||
@@ -920,6 +947,7 @@ type selectsMockModuleProperties struct {
|
||||
My_string_list proptools.Configurable[[]string]
|
||||
My_paths proptools.Configurable[[]string] `android:"path"`
|
||||
Replacing_string_list proptools.Configurable[[]string] `android:"replace_instead_of_append,arch_variant"`
|
||||
Arch_variant_configurable_bool proptools.Configurable[bool] `android:"replace_instead_of_append,arch_variant"`
|
||||
My_nonconfigurable_bool *bool
|
||||
My_nonconfigurable_string *string
|
||||
My_nonconfigurable_string_list []string
|
||||
@@ -950,6 +978,7 @@ func (p *selectsMockModule) GenerateAndroidBuildActions(ctx ModuleContext) {
|
||||
my_string_list: optionalToPtr(p.properties.My_string_list.Get(ctx)),
|
||||
my_paths: optionalToPtr(p.properties.My_paths.Get(ctx)),
|
||||
replacing_string_list: optionalToPtr(p.properties.Replacing_string_list.Get(ctx)),
|
||||
arch_variant_configurable_bool: optionalToPtr(p.properties.Arch_variant_configurable_bool.Get(ctx)),
|
||||
my_nonconfigurable_bool: p.properties.My_nonconfigurable_bool,
|
||||
my_nonconfigurable_string: p.properties.My_nonconfigurable_string,
|
||||
my_nonconfigurable_string_list: p.properties.My_nonconfigurable_string_list,
|
||||
|
Reference in New Issue
Block a user