summaryrefslogtreecommitdiff
path: root/android/soongconfig/modules_test.go
diff options
context:
space:
mode:
author Cole Faust <colefaust@google.com> 2022-11-01 17:10:23 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2022-11-01 17:10:23 +0000
commitb0a91330bb78c69630c67d33873c106a04b890ec (patch)
tree1815a8d0de21be521ca1f8fd8c715b0ec16c2ffc /android/soongconfig/modules_test.go
parentb7b2e124751f44a3b659c5b08deb0684b0041cfe (diff)
Revert^4 "Prevent unspecified values in soong_config_string_variables"
This reverts commit b7b2e124751f44a3b659c5b08deb0684b0041cfe. Reason for revert: Issues on -plus-aosp branches have been fixed Change-Id: Ie2f7ce45502b999280e099d9c0f9d0f7d6b7ba08
Diffstat (limited to 'android/soongconfig/modules_test.go')
-rw-r--r--android/soongconfig/modules_test.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/android/soongconfig/modules_test.go b/android/soongconfig/modules_test.go
index a7800e8ef..d5d87efc0 100644
--- a/android/soongconfig/modules_test.go
+++ b/android/soongconfig/modules_test.go
@@ -303,6 +303,10 @@ type soongConfigVars struct {
Bool_var interface{}
}
+type stringSoongConfigVars struct {
+ String_var interface{}
+}
+
func Test_PropertiesToApply(t *testing.T) {
mt, _ := newModuleType(&ModuleTypeProperties{
Module_type: "foo",
@@ -365,6 +369,51 @@ func Test_PropertiesToApply(t *testing.T) {
}
}
+func Test_PropertiesToApply_String_Error(t *testing.T) {
+ mt, _ := newModuleType(&ModuleTypeProperties{
+ Module_type: "foo",
+ Config_namespace: "bar",
+ Variables: []string{"string_var"},
+ Properties: []string{"a", "b"},
+ })
+ mt.Variables = append(mt.Variables, &stringVariable{
+ baseVariable: baseVariable{
+ variable: "string_var",
+ },
+ values: []string{"a", "b", "c"},
+ })
+ stringVarPositive := &properties{
+ A: proptools.StringPtr("A"),
+ B: true,
+ }
+ conditionsDefault := &properties{
+ A: proptools.StringPtr("default"),
+ B: false,
+ }
+ actualProps := &struct {
+ Soong_config_variables stringSoongConfigVars
+ }{
+ Soong_config_variables: stringSoongConfigVars{
+ String_var: &boolVarProps{
+ A: stringVarPositive.A,
+ B: stringVarPositive.B,
+ Conditions_default: conditionsDefault,
+ },
+ },
+ }
+ props := reflect.ValueOf(actualProps)
+
+ _, err := PropertiesToApply(mt, props, Config(map[string]string{
+ "string_var": "x",
+ }))
+ expected := `Soong config property "string_var" must be one of [a b c], found "x"`
+ if err == nil {
+ t.Fatalf("Expected an error, got nil")
+ } else if err.Error() != expected {
+ t.Fatalf("Error message was not correct, expected %q, got %q", expected, err.Error())
+ }
+}
+
func Test_Bp2BuildSoongConfigDefinitions(t *testing.T) {
testCases := []struct {
desc string