Improve sdk snapshot testing

The sdk produces snapshots that are expected to be unpacked in one of
the Android repos. Often that can lead to issues due to conflicts
between the source and prebuilts. This change attempts to avoid those
conflicts by testing the different ways that those files can be used.

With the existing test to cover adding the snapshot
This change will cause the sdk tests to check the following:
1) Snapshot on its own (already done).
2) Snapshot plus original source where the original source is
   preferred.
3) Snapshot plus original source where the snapshot is preferred.

It also adds the ability for tests to provide their own custom checkers
to verify the result of each of the previous tests.

This change reveals a number of bugs already present. Rather than
attempt to fix them this change adds the ability to specify error
handlers for the two cases that mix source and snapshot to allow those
errors to be temporarily ignored while allowing the majority of the
tests to benefit from this improvement. Each of those failures has a
TODO and bug associated with it.

Bug: 183184375
Test: m nothing
Change-Id: I105233195074dbe7a6422b6dfc5486e74398ea15
This commit is contained in:
Paul Duffin
2021-03-21 12:56:33 +00:00
parent 2b1d2b6e4d
commit 1822a0a371
5 changed files with 172 additions and 49 deletions

View File

@@ -48,42 +48,17 @@ func TestSdkDependsOnSourceEvenWhenPrebuiltPreferred(t *testing.T) {
system_modules: "none",
sdk_version: "none",
}
java_import {
name: "sdkmember",
prefer: true,
jars: ["prebuilt.jar"],
}
`)
// Make sure that the mysdk module depends on "sdkmember" and not "prebuilt_sdkmember".
java.CheckModuleDependencies(t, result.TestContext, "mysdk", "android_common", []string{"sdkmember"})
sdkChecker := func(t *testing.T, result *android.TestResult) {
java.CheckModuleDependencies(t, result.TestContext, "mysdk", "android_common", []string{"sdkmember"})
}
CheckSnapshot(t, result, "mysdk", "",
checkAndroidBpContents(`// This is auto-generated. DO NOT EDIT.
java_import {
name: "mysdk_sdkmember@current",
sdk_member_name: "sdkmember",
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
jars: ["java/sdkmember.jar"],
}
java_import {
name: "sdkmember",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
jars: ["java/sdkmember.jar"],
}
sdk_snapshot {
name: "mysdk@current",
visibility: ["//visibility:public"],
java_header_libs: ["mysdk_sdkmember@current"],
}
`))
snapshotTestChecker(checkSnapshotWithSourcePreferred, sdkChecker),
snapshotTestChecker(checkSnapshotPreferredWithSource, sdkChecker),
)
}
func TestBasicSdkWithJavaLibrary(t *testing.T) {