Remove more bp2build
Bug: 315353489 Test: m blueprint_tests Change-Id: Ib854fe1a448c258fe086691a6e5ed2d98537f5e4
This commit is contained in:
@@ -413,220 +413,3 @@ func Test_PropertiesToApply_String_Error(t *testing.T) {
|
||||
t.Fatalf("Error message was not correct, expected %q, got %q", expected, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func Test_Bp2BuildSoongConfigDefinitionsAddVars(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
defs []*SoongConfigDefinition
|
||||
expected Bp2BuildSoongConfigDefinitions
|
||||
}{
|
||||
{
|
||||
desc: "non-overlapping",
|
||||
defs: []*SoongConfigDefinition{
|
||||
&SoongConfigDefinition{
|
||||
ModuleTypes: map[string]*ModuleType{
|
||||
"a": &ModuleType{
|
||||
ConfigNamespace: "foo",
|
||||
Variables: []soongConfigVariable{
|
||||
&stringVariable{
|
||||
baseVariable: baseVariable{"string_var"},
|
||||
values: []string{"a", "b", "c"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
&SoongConfigDefinition{
|
||||
ModuleTypes: map[string]*ModuleType{
|
||||
"b": &ModuleType{
|
||||
ConfigNamespace: "foo",
|
||||
Variables: []soongConfigVariable{
|
||||
&stringVariable{
|
||||
baseVariable: baseVariable{"string_var"},
|
||||
values: []string{"a", "b", "c"},
|
||||
},
|
||||
&boolVariable{baseVariable: baseVariable{"bool_var"}},
|
||||
&valueVariable{baseVariable: baseVariable{"variable_var"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: Bp2BuildSoongConfigDefinitions{
|
||||
StringVars: map[string]map[string]bool{
|
||||
"foo__string_var": map[string]bool{"a": true, "b": true, "c": true},
|
||||
},
|
||||
BoolVars: map[string]bool{"foo__bool_var": true},
|
||||
ValueVars: map[string]bool{"foo__variable_var": true},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "overlapping",
|
||||
defs: []*SoongConfigDefinition{
|
||||
&SoongConfigDefinition{
|
||||
ModuleTypes: map[string]*ModuleType{
|
||||
"a": &ModuleType{
|
||||
ConfigNamespace: "foo",
|
||||
Variables: []soongConfigVariable{
|
||||
&stringVariable{
|
||||
baseVariable: baseVariable{"string_var"},
|
||||
values: []string{"a", "b", "c"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
&SoongConfigDefinition{
|
||||
ModuleTypes: map[string]*ModuleType{
|
||||
"b": &ModuleType{
|
||||
ConfigNamespace: "foo",
|
||||
Variables: []soongConfigVariable{
|
||||
&stringVariable{
|
||||
baseVariable: baseVariable{"string_var"},
|
||||
values: []string{"b", "c", "d"},
|
||||
},
|
||||
&boolVariable{baseVariable: baseVariable{"bool_var"}},
|
||||
&valueVariable{baseVariable: baseVariable{"variable_var"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: Bp2BuildSoongConfigDefinitions{
|
||||
StringVars: map[string]map[string]bool{
|
||||
"foo__string_var": map[string]bool{"a": true, "b": true, "c": true, "d": true},
|
||||
},
|
||||
BoolVars: map[string]bool{"foo__bool_var": true},
|
||||
ValueVars: map[string]bool{"foo__variable_var": true},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
actual := &Bp2BuildSoongConfigDefinitions{}
|
||||
for _, d := range tc.defs {
|
||||
func(def *SoongConfigDefinition) {
|
||||
actual.AddVars(def)
|
||||
}(d)
|
||||
}
|
||||
if !reflect.DeepEqual(*actual, tc.expected) {
|
||||
t.Errorf("Expected %#v, got %#v", tc.expected, *actual)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func Test_Bp2BuildSoongConfigDefinitions(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
defs Bp2BuildSoongConfigDefinitions
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
desc: "all empty",
|
||||
defs: Bp2BuildSoongConfigDefinitions{},
|
||||
expected: `soong_config_bool_variables = {}
|
||||
|
||||
soong_config_value_variables = {}
|
||||
|
||||
soong_config_string_variables = {}`}, {
|
||||
desc: "only bool",
|
||||
defs: Bp2BuildSoongConfigDefinitions{
|
||||
BoolVars: map[string]bool{
|
||||
"bool_var": true,
|
||||
},
|
||||
},
|
||||
expected: `soong_config_bool_variables = {
|
||||
"bool_var": True,
|
||||
}
|
||||
|
||||
soong_config_value_variables = {}
|
||||
|
||||
soong_config_string_variables = {}`}, {
|
||||
desc: "only value vars",
|
||||
defs: Bp2BuildSoongConfigDefinitions{
|
||||
ValueVars: map[string]bool{
|
||||
"value_var": true,
|
||||
},
|
||||
},
|
||||
expected: `soong_config_bool_variables = {}
|
||||
|
||||
soong_config_value_variables = {
|
||||
"value_var": True,
|
||||
}
|
||||
|
||||
soong_config_string_variables = {}`}, {
|
||||
desc: "only string vars",
|
||||
defs: Bp2BuildSoongConfigDefinitions{
|
||||
StringVars: map[string]map[string]bool{
|
||||
"string_var": map[string]bool{
|
||||
"choice1": true,
|
||||
"choice2": true,
|
||||
"choice3": true,
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: `soong_config_bool_variables = {}
|
||||
|
||||
soong_config_value_variables = {}
|
||||
|
||||
soong_config_string_variables = {
|
||||
"string_var": [
|
||||
"choice1",
|
||||
"choice2",
|
||||
"choice3",
|
||||
],
|
||||
}`}, {
|
||||
desc: "all vars",
|
||||
defs: Bp2BuildSoongConfigDefinitions{
|
||||
BoolVars: map[string]bool{
|
||||
"bool_var_one": true,
|
||||
},
|
||||
ValueVars: map[string]bool{
|
||||
"value_var_one": true,
|
||||
"value_var_two": true,
|
||||
},
|
||||
StringVars: map[string]map[string]bool{
|
||||
"string_var_one": map[string]bool{
|
||||
"choice1": true,
|
||||
"choice2": true,
|
||||
"choice3": true,
|
||||
},
|
||||
"string_var_two": map[string]bool{
|
||||
"foo": true,
|
||||
"bar": true,
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: `soong_config_bool_variables = {
|
||||
"bool_var_one": True,
|
||||
}
|
||||
|
||||
soong_config_value_variables = {
|
||||
"value_var_one": True,
|
||||
"value_var_two": True,
|
||||
}
|
||||
|
||||
soong_config_string_variables = {
|
||||
"string_var_one": [
|
||||
"choice1",
|
||||
"choice2",
|
||||
"choice3",
|
||||
],
|
||||
"string_var_two": [
|
||||
"bar",
|
||||
"foo",
|
||||
],
|
||||
}`},
|
||||
}
|
||||
for _, test := range testCases {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
actual := test.defs.String()
|
||||
if actual != test.expected {
|
||||
t.Errorf("Expected:\n%s\nbut got:\n%s", test.expected, actual)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user