Return all rules when TestingModule.Rule fails
Similarly to Output, we return the list of Rules that have been generated for TestingModule. This helps debugging failing tests. Test: m nothing Change-Id: I3542f4e4632f94fb84208c2e48e629271a373fd4
This commit is contained in:
parent
1fde95ac3f
commit
3600b80e6f
|
@ -187,19 +187,21 @@ func newTestingBuildParams(provider testBuildProvider, bparams BuildParams) Test
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func maybeBuildParamsFromRule(provider testBuildProvider, rule string) TestingBuildParams {
|
func maybeBuildParamsFromRule(provider testBuildProvider, rule string) (TestingBuildParams, []string) {
|
||||||
|
var searchedRules []string
|
||||||
for _, p := range provider.BuildParamsForTests() {
|
for _, p := range provider.BuildParamsForTests() {
|
||||||
|
searchedRules = append(searchedRules, p.Rule.String())
|
||||||
if strings.Contains(p.Rule.String(), rule) {
|
if strings.Contains(p.Rule.String(), rule) {
|
||||||
return newTestingBuildParams(provider, p)
|
return newTestingBuildParams(provider, p), searchedRules
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TestingBuildParams{}
|
return TestingBuildParams{}, searchedRules
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildParamsFromRule(provider testBuildProvider, rule string) TestingBuildParams {
|
func buildParamsFromRule(provider testBuildProvider, rule string) TestingBuildParams {
|
||||||
p := maybeBuildParamsFromRule(provider, rule)
|
p, searchRules := maybeBuildParamsFromRule(provider, rule)
|
||||||
if p.Rule == nil {
|
if p.Rule == nil {
|
||||||
panic(fmt.Errorf("couldn't find rule %q", rule))
|
panic(fmt.Errorf("couldn't find rule %q.\nall rules: %v", rule, searchRules))
|
||||||
}
|
}
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
@ -275,7 +277,8 @@ func (m TestingModule) Module() Module {
|
||||||
// MaybeRule finds a call to ctx.Build with BuildParams.Rule set to a rule with the given name. Returns an empty
|
// MaybeRule finds a call to ctx.Build with BuildParams.Rule set to a rule with the given name. Returns an empty
|
||||||
// BuildParams if no rule is found.
|
// BuildParams if no rule is found.
|
||||||
func (m TestingModule) MaybeRule(rule string) TestingBuildParams {
|
func (m TestingModule) MaybeRule(rule string) TestingBuildParams {
|
||||||
return maybeBuildParamsFromRule(m.module, rule)
|
r, _ := maybeBuildParamsFromRule(m.module, rule)
|
||||||
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rule finds a call to ctx.Build with BuildParams.Rule set to a rule with the given name. Panics if no rule is found.
|
// Rule finds a call to ctx.Build with BuildParams.Rule set to a rule with the given name. Panics if no rule is found.
|
||||||
|
@ -328,7 +331,8 @@ func (s TestingSingleton) Singleton() Singleton {
|
||||||
// MaybeRule finds a call to ctx.Build with BuildParams.Rule set to a rule with the given name. Returns an empty
|
// MaybeRule finds a call to ctx.Build with BuildParams.Rule set to a rule with the given name. Returns an empty
|
||||||
// BuildParams if no rule is found.
|
// BuildParams if no rule is found.
|
||||||
func (s TestingSingleton) MaybeRule(rule string) TestingBuildParams {
|
func (s TestingSingleton) MaybeRule(rule string) TestingBuildParams {
|
||||||
return maybeBuildParamsFromRule(s.provider, rule)
|
r, _ := maybeBuildParamsFromRule(s.provider, rule)
|
||||||
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rule finds a call to ctx.Build with BuildParams.Rule set to a rule with the given name. Panics if no rule is found.
|
// Rule finds a call to ctx.Build with BuildParams.Rule set to a rule with the given name. Panics if no rule is found.
|
||||||
|
|
Loading…
Reference in New Issue