diff options
Diffstat (limited to 'sdk/testing.go')
-rw-r--r-- | sdk/testing.go | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/sdk/testing.go b/sdk/testing.go index ea0fe77d8..fac2f8e8a 100644 --- a/sdk/testing.go +++ b/sdk/testing.go @@ -186,13 +186,17 @@ type testSdkResult struct { *android.TestContext } +func (result *testSdkResult) Module(name string, variant string) android.Module { + return result.ModuleForTests(name, variant).Module() +} + // Analyse the sdk build rules to extract information about what it is doing. // e.g. find the src/dest pairs from each cp command, the various zip files // generated, etc. -func (r *testSdkResult) getSdkSnapshotBuildInfo(sdk *sdk) *snapshotBuildInfo { +func getSdkSnapshotBuildInfo(result *testSdkResult, sdk *sdk) *snapshotBuildInfo { info := &snapshotBuildInfo{ - r: r, + r: result, androidBpContents: sdk.GetAndroidBpContentsForTests(), androidUnversionedBpContents: sdk.GetUnversionedAndroidBpContentsForTests(), androidVersionedBpContents: sdk.GetVersionedAndroidBpContentsForTests(), @@ -235,7 +239,7 @@ func (r *testSdkResult) getSdkSnapshotBuildInfo(sdk *sdk) *snapshotBuildInfo { info.intermediateZip = info.outputZip mergeInput := android.NormalizePathForTesting(bp.Input) if info.intermediateZip != mergeInput { - r.Errorf("Expected intermediate zip %s to be an input to merge zips but found %s instead", + result.Errorf("Expected intermediate zip %s to be an input to merge zips but found %s instead", info.intermediateZip, mergeInput) } @@ -254,24 +258,20 @@ func (r *testSdkResult) getSdkSnapshotBuildInfo(sdk *sdk) *snapshotBuildInfo { return info } -func (r *testSdkResult) Module(name string, variant string) android.Module { - return r.ModuleForTests(name, variant).Module() -} - // Check the snapshot build rules. // // Takes a list of functions which check different facets of the snapshot build rules. // Allows each test to customize what is checked without duplicating lots of code // or proliferating check methods of different flavors. -func (r *testSdkResult) CheckSnapshot(name string, dir string, checkers ...snapshotBuildInfoChecker) { - r.Helper() +func CheckSnapshot(result *testSdkResult, name string, dir string, checkers ...snapshotBuildInfoChecker) { + result.Helper() // The sdk CommonOS variant is always responsible for generating the snapshot. variant := android.CommonOS.Name - sdk := r.Module(name, variant).(*sdk) + sdk := result.Module(name, variant).(*sdk) - snapshotBuildInfo := r.getSdkSnapshotBuildInfo(sdk) + snapshotBuildInfo := getSdkSnapshotBuildInfo(result, sdk) // Check state of the snapshot build. for _, checker := range checkers { @@ -283,7 +283,7 @@ func (r *testSdkResult) CheckSnapshot(name string, dir string, checkers ...snaps if dir != "" { dir = filepath.Clean(dir) + "/" } - r.AssertStringEquals("Snapshot zip file in wrong place", + result.AssertStringEquals("Snapshot zip file in wrong place", fmt.Sprintf(".intermediates/%s%s/%s/%s-current.zip", dir, name, variant, name), actual) // Populate a mock filesystem with the files that would have been copied by @@ -294,7 +294,7 @@ func (r *testSdkResult) CheckSnapshot(name string, dir string, checkers ...snaps } // Process the generated bp file to make sure it is valid. - testSdkWithFs(r.T, snapshotBuildInfo.androidBpContents, fs) + testSdkWithFs(result.T, snapshotBuildInfo.androidBpContents, fs) } type snapshotBuildInfoChecker func(info *snapshotBuildInfo) |