From 9cf27db425bd693ab17603bef740f2411363c3df Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 5 Dec 2017 09:26:15 -0800 Subject: [PATCH] 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 --- android/testing.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/android/testing.go b/android/testing.go index 1c0fac10d..ae012b06e 100644 --- a/android/testing.go +++ b/android/testing.go @@ -136,6 +136,7 @@ func (m TestingModule) Description(desc string) BuildParams { } 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 @@ func (m TestingModule) Output(file string) BuildParams { 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)) }