diff --git a/android/testing.go b/android/testing.go index 191cb8d02..b36f62cce 100644 --- a/android/testing.go +++ b/android/testing.go @@ -713,9 +713,11 @@ func (b baseTestingComponent) newTestingBuildParams(bparams BuildParams) Testing func (b baseTestingComponent) maybeBuildParamsFromRule(rule string) (TestingBuildParams, []string) { var searchedRules []string - for _, p := range b.provider.BuildParamsForTests() { - searchedRules = append(searchedRules, p.Rule.String()) - if strings.Contains(p.Rule.String(), rule) { + buildParams := b.provider.BuildParamsForTests() + for _, p := range buildParams { + ruleAsString := p.Rule.String() + searchedRules = append(searchedRules, ruleAsString) + if strings.Contains(ruleAsString, rule) { return b.newTestingBuildParams(p), searchedRules } } @@ -725,7 +727,7 @@ func (b baseTestingComponent) maybeBuildParamsFromRule(rule string) (TestingBuil func (b baseTestingComponent) buildParamsFromRule(rule string) TestingBuildParams { p, searchRules := b.maybeBuildParamsFromRule(rule) if p.Rule == nil { - panic(fmt.Errorf("couldn't find rule %q.\nall rules: %v", rule, searchRules)) + panic(fmt.Errorf("couldn't find rule %q.\nall rules:\n%s", rule, strings.Join(searchRules, "\n"))) } return p }