bootclasspath_fragment: Add contents to snapshot
Bug: 177892522
Test: m nothing
Change-Id: I54fe0537b758a0e3dacd34b139ef3eb21b8841fd
diff --git a/sdk/testing.go b/sdk/testing.go
index 9465e13..bf59aed 100644
--- a/sdk/testing.go
+++ b/sdk/testing.go
@@ -255,13 +255,14 @@
var runSnapshotTestWithCheckers = func(t *testing.T, testConfig snapshotTest, extraPreparer android.FixturePreparer) {
customization := snapshotBuildInfo.snapshotTestCustomization(testConfig)
+ customizedPreparers := android.GroupFixturePreparers(customization.preparers...)
// TODO(b/183184375): Set Config.TestAllowNonExistentPaths = false to verify that all the
// files the snapshot needs are actually copied into the snapshot.
// Run the snapshot with the snapshot preparer and the extra preparer, which must come after as
// it may need to modify parts of the MockFS populated by the snapshot preparer.
- result := android.GroupFixturePreparers(snapshotPreparer, extraPreparer).
+ result := android.GroupFixturePreparers(snapshotPreparer, extraPreparer, customizedPreparers).
ExtendWithErrorHandler(customization.errorHandler).
RunTest(t)
@@ -369,6 +370,15 @@
type resultChecker func(t *testing.T, result *android.TestResult)
+// snapshotTestPreparer registers a preparer that will be used to customize the specified
+// snapshotTest.
+func snapshotTestPreparer(snapshotTest snapshotTest, preparer android.FixturePreparer) snapshotBuildInfoChecker {
+ return func(info *snapshotBuildInfo) {
+ customization := info.snapshotTestCustomization(snapshotTest)
+ customization.preparers = append(customization.preparers, preparer)
+ }
+}
+
// snapshotTestChecker registers a checker that will be run against the result of processing the
// generated snapshot for the specified snapshotTest.
func snapshotTestChecker(snapshotTest snapshotTest, checker resultChecker) snapshotBuildInfoChecker {
@@ -395,6 +405,9 @@
// Encapsulates information provided by each test to customize a specific snapshotTest.
type snapshotTestCustomization struct {
+ // Preparers that are used to customize the test fixture before running the test.
+ preparers []android.FixturePreparer
+
// Checkers that are run on the result of processing the preferred snapshot in a specific test
// case.
checkers []resultChecker