cc_test: emit errors if there's duplicate in srcs am: a61ff2cec3 am: c7da1a6b81

am: f7b91be91f

Change-Id: Ie1c7c95979d43aab97bc0b80beb66a00d09ebae9
This commit is contained in:
Jooyung Han
2019-03-06 18:21:09 -08:00
committed by android-build-merger

View File

@@ -120,6 +120,10 @@ func testPerSrcMutator(mctx android.BottomUpMutatorContext) {
if m, ok := mctx.Module().(*Module); ok {
if test, ok := m.linker.(testPerSrc); ok {
if test.testPerSrc() && len(test.srcs()) > 0 {
if duplicate, found := checkDuplicate(test.srcs()); found {
mctx.PropertyErrorf("srcs", "found a duplicate entry %q", duplicate)
return
}
testNames := make([]string, len(test.srcs()))
for i, src := range test.srcs() {
testNames[i] = strings.TrimSuffix(filepath.Base(src), filepath.Ext(src))
@@ -133,6 +137,17 @@ func testPerSrcMutator(mctx android.BottomUpMutatorContext) {
}
}
func checkDuplicate(values []string) (duplicate string, found bool) {
seen := make(map[string]string)
for _, v := range values {
if duplicate, found = seen[v]; found {
return
}
seen[v] = v
}
return
}
type testDecorator struct {
Properties TestProperties
linker *baseLinker