Handle xsd config more like other partitions
This is prep work to add additional special handling for genrule
generated headers as there will be similar partitioning for those
headers.
Test: go test soong tests
Change-Id: Ib63e7e4f7554b2b7b7bc78b2825b20c05403216a
diff --git a/bazel/properties_test.go b/bazel/properties_test.go
index c56d11f..c98ae0e 100644
--- a/bazel/properties_test.go
+++ b/bazel/properties_test.go
@@ -125,6 +125,63 @@
}
}
}
+
+func TestSubtractBazelLabelListAttribute(t *testing.T) {
+ testCases := []struct {
+ haystack LabelListAttribute
+ needle LabelListAttribute
+ expected LabelListAttribute
+ }{
+ {
+ haystack: LabelListAttribute{
+ Value: makeLabelList(
+ []string{"a", "b", "a", "c"},
+ []string{"x", "x", "y", "z"},
+ ),
+ ConfigurableValues: configurableLabelLists{
+ ArchConfigurationAxis: labelListSelectValues{
+ "arm": makeLabelList([]string{"arm_1", "arm_2"}, []string{}),
+ "x86": makeLabelList([]string{"x86_3", "x86_4", "x86_5"}, []string{"x86_5"}),
+ },
+ },
+ },
+ needle: LabelListAttribute{
+ Value: makeLabelList(
+ []string{"d", "a"},
+ []string{"x", "y2", "z2"},
+ ),
+ ConfigurableValues: configurableLabelLists{
+ ArchConfigurationAxis: labelListSelectValues{
+ "arm": makeLabelList([]string{"arm_1", "arm_3"}, []string{}),
+ "x86": makeLabelList([]string{"x86_3", "x86_4"}, []string{"x86_6"}),
+ },
+ },
+ },
+ expected: LabelListAttribute{
+ Value: makeLabelList(
+ []string{"b", "c"},
+ []string{"x", "x", "y", "z"},
+ ),
+ ConfigurableValues: configurableLabelLists{
+ ArchConfigurationAxis: labelListSelectValues{
+ "arm": makeLabelList([]string{"arm_2"}, []string{}),
+ "x86": makeLabelList([]string{"x86_5"}, []string{"x86_5"}),
+ },
+ },
+ ForceSpecifyEmptyList: false,
+ EmitEmptyList: false,
+ Prepend: false,
+ },
+ },
+ }
+ for _, tc := range testCases {
+ got := SubtractBazelLabelListAttribute(tc.haystack, tc.needle)
+ if !reflect.DeepEqual(tc.expected, got) {
+ t.Fatalf("Expected\n%v, but got\n%v", tc.expected, got)
+ }
+ }
+}
+
func TestFirstUniqueBazelLabelList(t *testing.T) {
testCases := []struct {
originalLabelList LabelList
@@ -167,6 +224,46 @@
}
}
+func TestFirstUniqueBazelLabelListAttribute(t *testing.T) {
+ testCases := []struct {
+ originalLabelList LabelListAttribute
+ expectedUniqueLabelList LabelListAttribute
+ }{
+ {
+ originalLabelList: LabelListAttribute{
+ Value: makeLabelList(
+ []string{"a", "b", "a", "c"},
+ []string{"x", "x", "y", "z"},
+ ),
+ ConfigurableValues: configurableLabelLists{
+ ArchConfigurationAxis: labelListSelectValues{
+ "arm": makeLabelList([]string{"1", "2", "1"}, []string{}),
+ "x86": makeLabelList([]string{"3", "4", "4"}, []string{"5", "5"}),
+ },
+ },
+ },
+ expectedUniqueLabelList: LabelListAttribute{
+ Value: makeLabelList(
+ []string{"a", "b", "c"},
+ []string{"x", "y", "z"},
+ ),
+ ConfigurableValues: configurableLabelLists{
+ ArchConfigurationAxis: labelListSelectValues{
+ "arm": makeLabelList([]string{"1", "2"}, []string{}),
+ "x86": makeLabelList([]string{"3", "4"}, []string{"5"}),
+ },
+ },
+ },
+ },
+ }
+ for _, tc := range testCases {
+ actualUniqueLabelList := FirstUniqueBazelLabelListAttribute(tc.originalLabelList)
+ if !reflect.DeepEqual(tc.expectedUniqueLabelList, actualUniqueLabelList) {
+ t.Fatalf("Expected %v, got %v", tc.expectedUniqueLabelList, actualUniqueLabelList)
+ }
+ }
+}
+
func TestUniqueSortedBazelLabelList(t *testing.T) {
testCases := []struct {
originalLabelList LabelList