diff options
| author | 2019-06-10 15:15:17 -0700 | |
|---|---|---|
| committer | 2019-06-10 15:51:06 -0700 | |
| commit | b88b3c5e77a80ba3a9816bf16da67ce017cd6d56 (patch) | |
| tree | e6fdbdcc25809b6169bd4406b80e0702b44e14d5 | |
| parent | 2ffb9a8d7d334a17b779d1b96f1db1d001298aa0 (diff) | |
Capture missing dependency error rules
Allow missing dependency errors to be tested by capturing the
missing dependency error rule instead of the originally requested
rule.
Test: all soong tests
Change-Id: Id2b23b9ee354cdafc44fb9adfaf8fe7bab973478
| -rw-r--r-- | android/module.go | 33 | ||||
| -rw-r--r-- | android/testing.go | 2 |
2 files changed, 15 insertions, 20 deletions
diff --git a/android/module.go b/android/module.go index 2481000fe..3a9ef9636 100644 --- a/android/module.go +++ b/android/module.go @@ -945,17 +945,16 @@ type moduleContext struct { variables map[string]string } -func (m *moduleContext) ninjaError(desc string, outputs []string, err error) { - m.ModuleContext.Build(pctx.PackageContext, blueprint.BuildParams{ +func (m *moduleContext) ninjaError(params BuildParams, err error) (PackageContext, BuildParams) { + return pctx, BuildParams{ Rule: ErrorRule, - Description: desc, - Outputs: outputs, - Optional: true, + Description: params.Description, + Output: params.Output, + Outputs: params.Outputs, Args: map[string]string{ "error": err.Error(), }, - }) - return + } } func (m *moduleContext) Config() Config { @@ -1027,24 +1026,20 @@ func (m *moduleContext) Rule(pctx PackageContext, name string, params blueprint. } func (m *moduleContext) Build(pctx PackageContext, params BuildParams) { - if m.config.captureBuild { - m.buildParams = append(m.buildParams, params) + if params.Description != "" { + params.Description = "${moduleDesc}" + params.Description + "${moduleDescSuffix}" } - bparams := convertBuildParams(params) - - if bparams.Description != "" { - bparams.Description = "${moduleDesc}" + params.Description + "${moduleDescSuffix}" + if missingDeps := m.GetMissingDependencies(); len(missingDeps) > 0 { + pctx, params = m.ninjaError(params, fmt.Errorf("module %s missing dependencies: %s\n", + m.ModuleName(), strings.Join(missingDeps, ", "))) } - if missingDeps := m.GetMissingDependencies(); len(missingDeps) > 0 { - m.ninjaError(bparams.Description, bparams.Outputs, - fmt.Errorf("module %s missing dependencies: %s\n", - m.ModuleName(), strings.Join(missingDeps, ", "))) - return + if m.config.captureBuild { + m.buildParams = append(m.buildParams, params) } - m.ModuleContext.Build(pctx.PackageContext, bparams) + m.ModuleContext.Build(pctx.PackageContext, convertBuildParams(params)) } func (m *moduleContext) Module() Module { diff --git a/android/testing.go b/android/testing.go index c0db75ecc..44bee4b7d 100644 --- a/android/testing.go +++ b/android/testing.go @@ -179,7 +179,7 @@ func buildParamsFromRule(provider testBuildProvider, rule string) TestingBuildPa func maybeBuildParamsFromDescription(provider testBuildProvider, desc string) TestingBuildParams { for _, p := range provider.BuildParamsForTests() { - if p.Description == desc { + if strings.Contains(p.Description, desc) { return newTestingBuildParams(provider, p) } } |