Add package for printing starlark formatted data
Bug: 216168792 Test: build/bazel/ci/bp2build.sh Change-Id: I3a06b19396f7ffe1c638042cda7e731dd840f1d6
This commit is contained in:
@@ -367,19 +367,19 @@ func Test_PropertiesToApply(t *testing.T) {
|
||||
|
||||
func Test_Bp2BuildSoongConfigDefinitions(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
defs Bp2BuildSoongConfigDefinitions
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
desc: "all empty",
|
||||
defs: Bp2BuildSoongConfigDefinitions{},
|
||||
expected: `soong_config_bool_variables = {
|
||||
}
|
||||
expected: `soong_config_bool_variables = {}
|
||||
|
||||
soong_config_value_variables = {
|
||||
}
|
||||
soong_config_value_variables = {}
|
||||
|
||||
soong_config_string_variables = {
|
||||
}`}, {
|
||||
soong_config_string_variables = {}`}, {
|
||||
desc: "only bool",
|
||||
defs: Bp2BuildSoongConfigDefinitions{
|
||||
BoolVars: map[string]bool{
|
||||
"bool_var": true,
|
||||
@@ -389,39 +389,35 @@ soong_config_string_variables = {
|
||||
"bool_var": True,
|
||||
}
|
||||
|
||||
soong_config_value_variables = {
|
||||
}
|
||||
soong_config_value_variables = {}
|
||||
|
||||
soong_config_string_variables = {
|
||||
}`}, {
|
||||
soong_config_string_variables = {}`}, {
|
||||
desc: "only value vars",
|
||||
defs: Bp2BuildSoongConfigDefinitions{
|
||||
ValueVars: map[string]bool{
|
||||
"value_var": true,
|
||||
},
|
||||
},
|
||||
expected: `soong_config_bool_variables = {
|
||||
}
|
||||
expected: `soong_config_bool_variables = {}
|
||||
|
||||
soong_config_value_variables = {
|
||||
"value_var": True,
|
||||
}
|
||||
|
||||
soong_config_string_variables = {
|
||||
}`}, {
|
||||
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,
|
||||
StringVars: map[string][]string{
|
||||
"string_var": []string{
|
||||
"choice1",
|
||||
"choice2",
|
||||
"choice3",
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: `soong_config_bool_variables = {
|
||||
}
|
||||
expected: `soong_config_bool_variables = {}
|
||||
|
||||
soong_config_value_variables = {
|
||||
}
|
||||
soong_config_value_variables = {}
|
||||
|
||||
soong_config_string_variables = {
|
||||
"string_var": [
|
||||
@@ -430,6 +426,7 @@ soong_config_string_variables = {
|
||||
"choice3",
|
||||
],
|
||||
}`}, {
|
||||
desc: "all vars",
|
||||
defs: Bp2BuildSoongConfigDefinitions{
|
||||
BoolVars: map[string]bool{
|
||||
"bool_var_one": true,
|
||||
@@ -438,15 +435,15 @@ soong_config_string_variables = {
|
||||
"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,
|
||||
StringVars: map[string][]string{
|
||||
"string_var_one": []string{
|
||||
"choice1",
|
||||
"choice2",
|
||||
"choice3",
|
||||
},
|
||||
"string_var_two": map[string]bool{
|
||||
"foo": true,
|
||||
"bar": true,
|
||||
"string_var_two": []string{
|
||||
"foo",
|
||||
"bar",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -466,15 +463,17 @@ soong_config_string_variables = {
|
||||
"choice3",
|
||||
],
|
||||
"string_var_two": [
|
||||
"bar",
|
||||
"foo",
|
||||
"bar",
|
||||
],
|
||||
}`},
|
||||
}
|
||||
for _, test := range testCases {
|
||||
actual := test.defs.String()
|
||||
if actual != test.expected {
|
||||
t.Errorf("Expected:\n%s\nbut got:\n%s", test.expected, actual)
|
||||
}
|
||||
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