Use Label (string) instead of Label (struct) to dedupe
Using Label struct as the map key causes issues because it contains OriginalModuleName. The same module will have a different value for this property when called from inside a soong namespace vs from outside. If there are dups, we can just choose the first one. OriginalModuleName is often used with ModuleFromName, and that function panics if there are modules with the same name in two separate soong namespaces Test: go test ./bp2build ./bazel Change-Id: I2ee33efab03016a72f1eea99cb958b6198baeca2
This commit is contained in:
@@ -33,8 +33,12 @@ func TestUniqueBazelLabels(t *testing.T) {
|
||||
{Label: "b"},
|
||||
{Label: "a"},
|
||||
{Label: "c"},
|
||||
// namespaces
|
||||
{Label: "//foo:bar", OriginalModuleName: "bar"}, // when referenced from foo namespace
|
||||
{Label: "//foo:bar", OriginalModuleName: "//foo:bar"}, // when reference from root namespace
|
||||
},
|
||||
expectedUniqueLabels: []Label{
|
||||
{Label: "//foo:bar", OriginalModuleName: "bar"},
|
||||
{Label: "a"},
|
||||
{Label: "b"},
|
||||
{Label: "c"},
|
||||
@@ -194,6 +198,9 @@ func TestFirstUniqueBazelLabelList(t *testing.T) {
|
||||
{Label: "b"},
|
||||
{Label: "a"},
|
||||
{Label: "c"},
|
||||
// namespaces
|
||||
{Label: "//foo:bar", OriginalModuleName: "bar"}, // when referenced from foo namespace
|
||||
{Label: "//foo:bar", OriginalModuleName: "//foo:bar"}, // when referenced from root namespace
|
||||
},
|
||||
Excludes: []Label{
|
||||
{Label: "x"},
|
||||
@@ -207,6 +214,7 @@ func TestFirstUniqueBazelLabelList(t *testing.T) {
|
||||
{Label: "a"},
|
||||
{Label: "b"},
|
||||
{Label: "c"},
|
||||
{Label: "//foo:bar", OriginalModuleName: "bar"},
|
||||
},
|
||||
Excludes: []Label{
|
||||
{Label: "x"},
|
||||
|
Reference in New Issue
Block a user