Make TestModule.Output print a list of all outputs on error
Debugging when writing tests using TestModule.Outputs is
unnecessarily hard, it panics when an incorrect output path
is given but doesn't provide any help to figure out why.
Follow the pattern used by TestContext.ModuleForTests
and print the list of valid output paths on failure.
Test: m checkbuild
Change-Id: I50e8e2dfc2070bd538d47cf6495a489f727b1564
diff --git a/android/testing.go b/android/testing.go
index 1c0fac1..ae012b0 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -136,6 +136,7 @@
}
func (m TestingModule) Output(file string) BuildParams {
+ var searchedOutputs []string
for _, p := range m.module.BuildParamsForTests() {
outputs := append(WritablePaths(nil), p.Outputs...)
if p.Output != nil {
@@ -145,7 +146,9 @@
if f.String() == file || f.Rel() == file {
return p
}
+ searchedOutputs = append(searchedOutputs, f.Rel())
}
}
- panic(fmt.Errorf("couldn't find output %q", file))
+ panic(fmt.Errorf("couldn't find output %q.\nall outputs: %v",
+ file, searchedOutputs))
}