Shorten missing module panic message
Only print the list of variants of the matching module when ctx.ModuleForTesting finds the module but not the variant. Test: all soong tests Change-Id: I51ffdde4645db39ec1d37ec018e0dea11d74280e
This commit is contained in:
@@ -119,14 +119,24 @@ func (ctx *TestContext) ModuleForTests(name, variant string) TestingModule {
|
||||
|
||||
if module == nil {
|
||||
// find all the modules that do exist
|
||||
allModuleNames := []string{}
|
||||
var allModuleNames []string
|
||||
var allVariants []string
|
||||
ctx.VisitAllModules(func(m blueprint.Module) {
|
||||
allModuleNames = append(allModuleNames, m.(Module).Name()+"("+ctx.ModuleSubDir(m)+")")
|
||||
allModuleNames = append(allModuleNames, ctx.ModuleName(m))
|
||||
if ctx.ModuleName(m) == name {
|
||||
allVariants = append(allVariants, ctx.ModuleSubDir(m))
|
||||
}
|
||||
})
|
||||
sort.Strings(allModuleNames)
|
||||
sort.Strings(allVariants)
|
||||
|
||||
panic(fmt.Errorf("failed to find module %q variant %q. All modules:\n %s",
|
||||
name, variant, strings.Join(allModuleNames, "\n ")))
|
||||
if len(allVariants) == 0 {
|
||||
panic(fmt.Errorf("failed to find module %q. All modules:\n %s",
|
||||
name, strings.Join(allModuleNames, "\n ")))
|
||||
} else {
|
||||
panic(fmt.Errorf("failed to find module %q variant %q. All variants:\n %s",
|
||||
name, variant, strings.Join(allVariants, "\n ")))
|
||||
}
|
||||
}
|
||||
|
||||
return TestingModule{module}
|
||||
|
Reference in New Issue
Block a user