summaryrefslogtreecommitdiff
path: root/android/testing.go
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2020-08-11 12:02:11 -0700
committer Colin Cross <ccross@android.com> 2020-08-13 11:52:21 -0700
commitbeae6ecbd4fd9cdf9c809ab9994103bc3e7be04b (patch)
tree4dc9e9827d62a2c941bd097c7a8da28d1d690b7f /android/testing.go
parent29737cfc944f73f5c1095126d1d2d701b1a7db09 (diff)
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
Diffstat (limited to 'android/testing.go')
-rw-r--r--android/testing.go20
1 files changed, 15 insertions, 5 deletions
diff --git a/android/testing.go b/android/testing.go
index 696efb6f8..f32d745c2 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -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)
-
- panic(fmt.Errorf("failed to find module %q variant %q. All modules:\n %s",
- name, variant, strings.Join(allModuleNames, "\n ")))
+ sort.Strings(allVariants)
+
+ 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}