summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Cole Faust <colefaust@google.com> 2024-03-28 16:26:59 -0700
committer Cole Faust <colefaust@google.com> 2024-04-04 10:41:43 -0700
commit12c8ed460144f5a676acf66a5133691d8676d301 (patch)
treec75bfc3536f128f4c4d3097bce24aebd8cb14349
parente5e0fb0fe53d633531895882749f7191a120c915 (diff)
Add tests for "unset" select statements
See the blueprint cl for more information. Bug: 323382414 Test: m nothing --no-skip-soong-tests Change-Id: I3a0302f370e8e498556b219cbda70bdb0255f6ef
-rw-r--r--android/selects_test.go98
1 files changed, 97 insertions, 1 deletions
diff --git a/android/selects_test.go b/android/selects_test.go
index adbe59a70..f57fb4218 100644
--- a/android/selects_test.go
+++ b/android/selects_test.go
@@ -121,7 +121,21 @@ func TestSelects(t *testing.T) {
}),
}
`,
- expectedError: `can't assign bool value to string property "my_string\[1\]"`,
+ 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: `
+ my_module_type {
+ name: "foo",
+ my_string: select(soong_config_variable("my_namespace", "my_variable"), {
+ "a": false,
+ "b": true,
+ _: true,
+ }),
+ }
+ `,
+ expectedError: `can't assign bool value to string property "my_string\[0\]"`,
},
{
name: "String list non-default",
@@ -272,6 +286,88 @@ func TestSelects(t *testing.T) {
my_string: proptools.StringPtr("my_arm64"),
},
},
+ {
+ name: "Unset value",
+ bp: `
+ my_module_type {
+ name: "foo",
+ my_string: select(soong_config_variable("my_namespace", "my_variable"), {
+ "a": unset,
+ "b": "b",
+ _: "c",
+ })
+ }
+ `,
+ vendorVars: map[string]map[string]string{
+ "my_namespace": {
+ "my_variable": "a",
+ },
+ },
+ provider: selectsTestProvider{},
+ },
+ {
+ name: "Unset value on different branch",
+ bp: `
+ my_module_type {
+ name: "foo",
+ my_string: select(soong_config_variable("my_namespace", "my_variable"), {
+ "a": unset,
+ "b": "b",
+ _: "c",
+ })
+ }
+ `,
+ provider: selectsTestProvider{
+ my_string: proptools.StringPtr("c"),
+ },
+ },
+ {
+ name: "unset + unset = unset",
+ bp: `
+ my_module_type {
+ name: "foo",
+ my_string: select(soong_config_variable("my_namespace", "my_variable"), {
+ _: unset,
+ }) + select(soong_config_variable("my_namespace", "my_variable2"), {
+ _: unset,
+ })
+ }
+ `,
+ provider: selectsTestProvider{},
+ },
+ {
+ name: "unset + string = string",
+ bp: `
+ my_module_type {
+ name: "foo",
+ my_string: select(soong_config_variable("my_namespace", "my_variable"), {
+ _: unset,
+ }) + select(soong_config_variable("my_namespace", "my_variable2"), {
+ _: "a",
+ })
+ }
+ `,
+ provider: selectsTestProvider{
+ my_string: proptools.StringPtr("a"),
+ },
+ },
+ {
+ name: "unset + bool = bool",
+ bp: `
+ my_module_type {
+ name: "foo",
+ my_bool: select(soong_config_variable("my_namespace", "my_variable"), {
+ "a": true,
+ _: unset,
+ }) + select(soong_config_variable("my_namespace", "my_variable2"), {
+ _: true,
+ })
+ }
+ `,
+ provider: selectsTestProvider{
+ my_bool: proptools.BoolPtr(true),
+ },
+ },
}
for _, tc := range testCases {