Add test for configurable defaults applied to multiple modules am: 693494682f
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3063444 Change-Id: I5d89292e15a5c3f633ffc607f63645f92c32d053 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -28,6 +28,7 @@ func TestSelects(t *testing.T) {
|
||||
name string
|
||||
bp string
|
||||
provider selectsTestProvider
|
||||
providers map[string]selectsTestProvider
|
||||
vendorVars map[string]map[string]string
|
||||
expectedError string
|
||||
}{
|
||||
@@ -410,6 +411,42 @@ func TestSelects(t *testing.T) {
|
||||
my_string_list: &[]string{"b2", "b1"},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "defaults applied to multiple modules",
|
||||
bp: `
|
||||
my_module_type {
|
||||
name: "foo2",
|
||||
defaults: ["bar"],
|
||||
my_string_list: select(soong_config_variable("my_namespace", "my_variable"), {
|
||||
"a": ["a1"],
|
||||
default: ["b1"],
|
||||
}),
|
||||
}
|
||||
my_module_type {
|
||||
name: "foo",
|
||||
defaults: ["bar"],
|
||||
my_string_list: select(soong_config_variable("my_namespace", "my_variable"), {
|
||||
"a": ["a1"],
|
||||
default: ["b1"],
|
||||
}),
|
||||
}
|
||||
my_defaults {
|
||||
name: "bar",
|
||||
my_string_list: select(soong_config_variable("my_namespace", "my_variable2"), {
|
||||
"a": ["a2"],
|
||||
default: ["b2"],
|
||||
}),
|
||||
}
|
||||
`,
|
||||
providers: map[string]selectsTestProvider{
|
||||
"foo": {
|
||||
my_string_list: &[]string{"b2", "b1"},
|
||||
},
|
||||
"foo2": {
|
||||
my_string_list: &[]string{"b2", "b1"},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Replacing string list",
|
||||
bp: `
|
||||
@@ -617,10 +654,19 @@ func TestSelects(t *testing.T) {
|
||||
result := fixtures.RunTestWithBp(t, tc.bp)
|
||||
|
||||
if tc.expectedError == "" {
|
||||
m := result.ModuleForTests("foo", "android_arm64_armv8-a")
|
||||
if len(tc.providers) == 0 {
|
||||
tc.providers = map[string]selectsTestProvider{
|
||||
"foo": tc.provider,
|
||||
}
|
||||
}
|
||||
|
||||
for moduleName := range tc.providers {
|
||||
expected := tc.providers[moduleName]
|
||||
m := result.ModuleForTests(moduleName, "android_arm64_armv8-a")
|
||||
p, _ := OtherModuleProvider(result.testContext.OtherModuleProviderAdaptor(), m.Module(), selectsTestProviderKey)
|
||||
if !reflect.DeepEqual(p, tc.provider) {
|
||||
t.Errorf("Expected:\n %q\ngot:\n %q", tc.provider.String(), p.String())
|
||||
if !reflect.DeepEqual(p, expected) {
|
||||
t.Errorf("Expected:\n %q\ngot:\n %q", expected.String(), p.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user