diff options
Diffstat (limited to 'android/fixture.go')
-rw-r--r-- | android/fixture.go | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/android/fixture.go b/android/fixture.go index 928967d8c..4e445c0b0 100644 --- a/android/fixture.go +++ b/android/fixture.go @@ -381,6 +381,19 @@ func GroupFixturePreparers(preparers ...FixturePreparer) FixturePreparer { return &compositeFixturePreparer{dedupAndFlattenPreparers(nil, preparers)} } +// NullFixturePreparer is a preparer that does nothing. +var NullFixturePreparer = GroupFixturePreparers() + +// OptionalFixturePreparer will return the supplied preparer if it is non-nil, otherwise it will +// return the NullFixturePreparer +func OptionalFixturePreparer(preparer FixturePreparer) FixturePreparer { + if preparer == nil { + return NullFixturePreparer + } else { + return preparer + } +} + type simpleFixturePreparerVisitor func(preparer *simpleFixturePreparer) // FixturePreparer is an opaque interface that can change a fixture. @@ -493,6 +506,14 @@ var FixtureExpectsNoErrors = FixtureCustomErrorHandler( }, ) +// FixtureIgnoreErrors ignores any errors. +// +// If this is used then it is the responsibility of the test to check the TestResult.Errs does not +// contain any unexpected errors. +var FixtureIgnoreErrors = FixtureCustomErrorHandler(func(t *testing.T, result *TestResult) { + // Ignore the errors +}) + // FixtureExpectsAtLeastOneMatchingError returns an error handler that will cause the test to fail // if at least one error that matches the regular expression is not found. // @@ -561,6 +582,10 @@ type TestResult struct { // The errors that were reported during the test. Errs []error + + // The ninja deps is a list of the ninja files dependencies that were added by the modules and + // singletons via the *.AddNinjaFileDeps() methods. + NinjaDeps []string } var _ FixtureFactory = (*fixtureFactory)(nil) @@ -701,9 +726,14 @@ func (f *fixture) RunTest() *TestResult { } ctx.Register() - _, errs := ctx.ParseBlueprintsFiles("ignored") + var ninjaDeps []string + extraNinjaDeps, errs := ctx.ParseBlueprintsFiles("ignored") if len(errs) == 0 { - _, errs = ctx.PrepareBuildActions(f.config) + ninjaDeps = append(ninjaDeps, extraNinjaDeps...) + extraNinjaDeps, errs = ctx.PrepareBuildActions(f.config) + if len(errs) == 0 { + ninjaDeps = append(ninjaDeps, extraNinjaDeps...) + } } result := &TestResult{ @@ -711,6 +741,7 @@ func (f *fixture) RunTest() *TestResult { fixture: f, Config: f.config, Errs: errs, + NinjaDeps: ninjaDeps, } f.errorHandler.CheckErrors(f.t, result) |