diff options
author | 2020-05-04 16:03:44 +0000 | |
---|---|---|
committer | 2020-05-04 16:03:44 +0000 | |
commit | 9d6ea77c52fda15bae9b0364de1d94ced900bd20 (patch) | |
tree | d4ae40c406f601ee9b02d99891d14bccd765dcb3 /apex/apex_test.go | |
parent | 817133ee2ad00c0979befc98b20e616b1f4f9b2e (diff) | |
parent | 8cf899afcc69643f63350bc9f9f92677bb8feabd (diff) |
Merge "Ensure APEX's Java deps use stable SDKs."
Diffstat (limited to 'apex/apex_test.go')
-rw-r--r-- | apex/apex_test.go | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/apex/apex_test.go b/apex/apex_test.go index ec5268fa3..d30b4292b 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -1411,6 +1411,122 @@ func TestInvalidMinSdkVersion(t *testing.T) { `) } +func TestJavaStableSdkVersion(t *testing.T) { + testCases := []struct { + name string + expectedError string + bp string + }{ + { + name: "Non-updatable apex with non-stable dep", + bp: ` + apex { + name: "myapex", + java_libs: ["myjar"], + key: "myapex.key", + } + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + java_library { + name: "myjar", + srcs: ["foo/bar/MyClass.java"], + sdk_version: "core_platform", + apex_available: ["myapex"], + } + `, + }, + { + name: "Updatable apex with stable dep", + bp: ` + apex { + name: "myapex", + java_libs: ["myjar"], + key: "myapex.key", + updatable: true, + min_sdk_version: "29", + } + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + java_library { + name: "myjar", + srcs: ["foo/bar/MyClass.java"], + sdk_version: "current", + apex_available: ["myapex"], + } + `, + }, + { + name: "Updatable apex with non-stable dep", + expectedError: "cannot depend on \"myjar\"", + bp: ` + apex { + name: "myapex", + java_libs: ["myjar"], + key: "myapex.key", + updatable: true, + } + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + java_library { + name: "myjar", + srcs: ["foo/bar/MyClass.java"], + sdk_version: "core_platform", + apex_available: ["myapex"], + } + `, + }, + { + name: "Updatable apex with non-stable transitive dep", + expectedError: "compiles against Android API, but dependency \"transitive-jar\" is compiling against non-public Android API.", + bp: ` + apex { + name: "myapex", + java_libs: ["myjar"], + key: "myapex.key", + updatable: true, + } + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + java_library { + name: "myjar", + srcs: ["foo/bar/MyClass.java"], + sdk_version: "current", + apex_available: ["myapex"], + static_libs: ["transitive-jar"], + } + java_library { + name: "transitive-jar", + srcs: ["foo/bar/MyClass.java"], + sdk_version: "core_platform", + apex_available: ["myapex"], + } + `, + }, + } + + for _, test := range testCases { + t.Run(test.name, func(t *testing.T) { + if test.expectedError == "" { + testApex(t, test.bp) + } else { + testApexError(t, test.expectedError, test.bp) + } + }) + } +} + func TestFilesInSubDir(t *testing.T) { ctx, _ := testApex(t, ` apex { @@ -4458,6 +4574,7 @@ func TestNoUpdatableJarsInBootImage(t *testing.T) { java_library { name: "some-updatable-apex-lib", srcs: ["a.java"], + sdk_version: "current", apex_available: [ "some-updatable-apex", ], @@ -4474,12 +4591,14 @@ func TestNoUpdatableJarsInBootImage(t *testing.T) { java_library { name: "some-platform-lib", srcs: ["a.java"], + sdk_version: "current", installable: true, } java_library { name: "some-art-lib", srcs: ["a.java"], + sdk_version: "current", apex_available: [ "com.android.art.something", ], |