check-flagged-apis: parse API versions XML
Teach check-flagged-apis to parse API versions XML; this represents the APIs after metalava has processed the source and kept APIs as is, or reverted them to the previous SDK snapshot, according to their @FlaggedApi flags. As with the API signature parser, limit support to fields to keep things simple; support for classes and methods will be added in later CLs. Note: `m sdk dist` will generate an API versions XML file. Bug: 334870672 Test: atest --host check-flagged-apis-test Test: check-flagged-apis --api-signature out/target/product/mainline_x86/obj/ETC/frameworks-base-api-current.txt_intermediates/frameworks-base-api-current.txt --flag-values out/soong/.intermediates/all_aconfig_declarations.pb --api-versions out/dist/data/api-versions.xml Change-Id: I779a0d0cdb8a50536d3fc8d517fa38ba4b0dcd1c
This commit is contained in:
@@ -52,6 +52,18 @@ private val PARSED_FLAGS =
|
||||
ByteArrayInputStream(binaryProto.toByteArray())
|
||||
}()
|
||||
|
||||
private val API_VERSIONS =
|
||||
"""
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<api version="3">
|
||||
<class name="android/Clazz" since="1">
|
||||
<method name="<init>()V"/>
|
||||
<field name="FOO"/>
|
||||
</class>
|
||||
</api>
|
||||
"""
|
||||
.trim()
|
||||
|
||||
@RunWith(DeviceJUnit4ClassRunner::class)
|
||||
class CheckFlaggedApisTest : BaseHostJUnit4Test() {
|
||||
@Test
|
||||
@@ -67,4 +79,11 @@ class CheckFlaggedApisTest : BaseHostJUnit4Test() {
|
||||
val actual = parseFlagValues(PARSED_FLAGS)
|
||||
assertEquals(expected, actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testParseApiVersions() {
|
||||
val expected: Set<Symbol> = setOf(Symbol("android.Clazz.FOO"))
|
||||
val actual = parseApiVersions(API_VERSIONS.byteInputStream())
|
||||
assertEquals(expected, actual)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user