Fix //conditions:default excludes computation for LabelListAttribute.

Previously, excludes computation for the default condition in label list
selects was clobbering pre-existing values. This CL fixes it by
performing a union of the new values with existing ones instead.

Test: properties_test.go
Bug: 198556411
Change-Id: Id11f4fb14e359201304afde0d8ba856851d41395
This commit is contained in:
Jingwen Chen
2021-11-02 10:27:17 +00:00
parent 55bc820d66
commit 9af49a49f8
2 changed files with 36 additions and 19 deletions

View File

@@ -534,9 +534,13 @@ func (lla *LabelListAttribute) ResolveExcludes() {
lla.ConfigurableValues[axis][config] = SubtractBazelLabelList(val, lla.Value)
}
// Now that the Value list is finalized for this axis, compare it with the original
// list, and put the difference into the default condition for the axis.
lla.ConfigurableValues[axis][ConditionsDefaultConfigKey] = SubtractBazelLabelList(baseLabels, lla.Value)
// Now that the Value list is finalized for this axis, compare it with
// the original list, and union the difference with the default
// condition for the axis.
difference := SubtractBazelLabelList(baseLabels, lla.Value)
existingDefaults := lla.ConfigurableValues[axis][ConditionsDefaultConfigKey]
existingDefaults.Append(difference)
lla.ConfigurableValues[axis][ConditionsDefaultConfigKey] = FirstUniqueBazelLabelList(existingDefaults)
// if everything ends up without includes, just delete the axis
if !lla.ConfigurableValues[axis].HasConfigurableValues() {