summaryrefslogtreecommitdiff
path: root/java/testing.go
diff options
context:
space:
mode:
Diffstat (limited to 'java/testing.go')
-rw-r--r--java/testing.go64
1 files changed, 20 insertions, 44 deletions
diff --git a/java/testing.go b/java/testing.go
index 896bcf8df..b0290dc3d 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -24,8 +24,6 @@ import (
"android/soong/android"
"android/soong/cc"
"android/soong/dexpreopt"
- "android/soong/python"
-
"github.com/google/blueprint"
)
@@ -41,18 +39,23 @@ const defaultJavaDir = "default/java"
// module types as possible. The exceptions are those module types that require mutators and/or
// singletons in order to function in which case they should be kept together in a separate
// preparer.
-var PrepareForTestWithJavaBuildComponents = android.FixtureRegisterWithContext(RegisterRequiredBuildComponentsForTest)
+var PrepareForTestWithJavaBuildComponents = android.GroupFixturePreparers(
+ // Make sure that mutators and module types, e.g. prebuilt mutators available.
+ android.PrepareForTestWithAndroidBuildComponents,
+ // Make java build components available to the test.
+ android.FixtureRegisterWithContext(RegisterRequiredBuildComponentsForTest),
+)
// Test fixture preparer that will define default java modules, e.g. standard prebuilt modules.
var PrepareForTestWithJavaDefaultModules = android.GroupFixturePreparers(
- // Make sure that mutators and module types, e.g. prebuilt mutators available.
- android.PrepareForTestWithAndroidBuildComponents,
// Make sure that all the module types used in the defaults are registered.
PrepareForTestWithJavaBuildComponents,
// The java default module definitions.
android.FixtureAddTextFile(defaultJavaDir+"/Android.bp", GatherRequiredDepsForTest()),
)
+var PrepareForTestWithOverlayBuildComponents = android.FixtureRegisterWithContext(registerOverlayBuildComponents)
+
// Prepare a fixture to use all java module types, mutators and singletons fully.
//
// This should only be used by tests that want to run with as much of the build enabled as possible.
@@ -62,9 +65,7 @@ var PrepareForIntegrationTestWithJava = android.GroupFixturePreparers(
)
// Prepare a fixture with the standard files required by a java_sdk_library module.
-var PrepareForTestWithJavaSdkLibraryFiles = android.FixtureMergeMockFs(javaSdkLibraryFiles)
-
-var javaSdkLibraryFiles = android.MockFS{
+var PrepareForTestWithJavaSdkLibraryFiles = android.FixtureMergeMockFs(android.MockFS{
"api/current.txt": nil,
"api/removed.txt": nil,
"api/system-current.txt": nil,
@@ -75,7 +76,7 @@ var javaSdkLibraryFiles = android.MockFS{
"api/module-lib-removed.txt": nil,
"api/system-server-current.txt": nil,
"api/system-server-removed.txt": nil,
-}
+})
// FixtureWithLastReleaseApis creates a preparer that creates prebuilt versions of the specified
// modules for the `last` API release. By `last` it just means last in the list of supplied versions
@@ -127,49 +128,15 @@ func FixtureWithPrebuiltApis(release2Modules map[string][]string) android.Fixtur
mockFS.Merge(prebuiltApisFilesForLibs([]string{release}, libs))
}
return android.GroupFixturePreparers(
- // A temporary measure to discard the definitions provided by default by javaMockFS() to allow
- // the changes that use this preparer to fix tests to be separated from the change to remove
- // javaMockFS().
- android.FixtureModifyMockFS(func(fs android.MockFS) {
- for k, _ := range fs {
- if strings.HasPrefix(k, "prebuilts/sdk/") {
- delete(fs, k)
- }
- }
- }),
android.FixtureAddTextFile(path, bp),
android.FixtureMergeMockFs(mockFS),
)
}
-func javaMockFS() android.MockFS {
- mockFS := android.MockFS{
- "prebuilts/sdk/tools/core-lambda-stubs.jar": nil,
- "prebuilts/sdk/Android.bp": []byte(`prebuilt_apis { name: "sdk", api_dirs: ["14", "28", "30", "current"], imports_sdk_version: "none", imports_compile_dex:true,}`),
-
- "bin.py": nil,
- python.StubTemplateHost: []byte(`PYTHON_BINARY = '%interpreter%'
- MAIN_FILE = '%main%'`),
- }
-
- levels := []string{"14", "28", "29", "30", "current"}
- libs := []string{
- "android", "foo", "bar", "sdklib", "barney", "betty", "foo-shared_library",
- "foo-no_shared_library", "core-for-system-modules", "quuz", "qux", "fred",
- "runtime-library",
- }
- for k, v := range prebuiltApisFilesForLibs(levels, libs) {
- mockFS[k] = v
- }
-
- return mockFS
-}
-
func TestConfig(buildDir string, env map[string]string, bp string, fs map[string][]byte) android.Config {
bp += GatherRequiredDepsForTest()
- mockFS := javaMockFS()
- mockFS.Merge(javaSdkLibraryFiles)
+ mockFS := android.MockFS{}
cc.GatherRequiredFilesForTest(mockFS)
@@ -354,3 +321,12 @@ func CheckHiddenAPIRuleInputs(t *testing.T, expected string, hiddenAPIRule andro
t.Errorf("Expected hiddenapi rule inputs:\n%s\nactual inputs:\n%s", expected, actual)
}
}
+
+// Check that the merged file create by platform_compat_config_singleton has the correct inputs.
+func CheckMergedCompatConfigInputs(t *testing.T, result *android.TestResult, message string, expectedPaths ...string) {
+ sourceGlobalCompatConfig := result.SingletonForTests("platform_compat_config_singleton")
+ allOutputs := sourceGlobalCompatConfig.AllOutputs()
+ android.AssertIntEquals(t, message+": output len", 1, len(allOutputs))
+ output := sourceGlobalCompatConfig.Output(allOutputs[0])
+ android.AssertPathsRelativeToTopEquals(t, message+": inputs", expectedPaths, output.Implicits)
+}