Avoid duplicate module names in the error from ModuleForTests.

#codehealth

Test: m nothing
Change-Id: Ia7c3191440452ce04782701bc6ef99251e55af4d
This commit is contained in:
Martin Stjernholm 2021-09-09 21:34:02 +01:00
parent ba839f8070
commit 98e0d88aac

View file

@ -509,12 +509,11 @@ func (ctx *TestContext) ModuleForTests(name, variant string) TestingModule {
allVariants = append(allVariants, ctx.ModuleSubDir(m))
}
})
sort.Strings(allModuleNames)
sort.Strings(allVariants)
if len(allVariants) == 0 {
panic(fmt.Errorf("failed to find module %q. All modules:\n %s",
name, strings.Join(allModuleNames, "\n ")))
name, strings.Join(SortedUniqueStrings(allModuleNames), "\n ")))
} else {
panic(fmt.Errorf("failed to find module %q variant %q. All variants:\n %s",
name, variant, strings.Join(allVariants, "\n ")))