Write/read module annotation FQ names to/from metadata on JVM

#KT-22759 In Progress
This commit is contained in:
Alexander Udalov
2018-01-18 13:57:41 +01:00
parent b4ac852392
commit ff33e0bad3
11 changed files with 1552 additions and 27 deletions
@@ -31,7 +31,8 @@ class JvmModuleProtoBufTest : KtUsefulTestCase() {
private fun doTest(
relativeDirectory: String,
compileWith: LanguageVersion = LanguageVersion.LATEST_STABLE,
loadWith: LanguageVersion = LanguageVersion.LATEST_STABLE
loadWith: LanguageVersion = LanguageVersion.LATEST_STABLE,
extraOptions: List<String> = emptyList()
) {
val directory = KotlinTestUtils.getTestDataPathBase() + relativeDirectory
val tmpdir = KotlinTestUtils.tmpDir(this::class.simpleName)
@@ -42,7 +43,7 @@ class JvmModuleProtoBufTest : KtUsefulTestCase() {
"-d", tmpdir.path,
"-module-name", moduleName,
"-language-version", compileWith.versionString
))
) + extraOptions)
val mapping = ModuleMapping.create(
File(tmpdir, "META-INF/$moduleName.${ModuleMapping.MAPPING_FILE_EXT}").readBytes(), "test",
@@ -51,6 +52,9 @@ class JvmModuleProtoBufTest : KtUsefulTestCase() {
)
)
val result = buildString {
for (annotationClassId in mapping.moduleData.annotations) {
appendln("@${annotationClassId.asString()}")
}
for ((fqName, packageParts) in mapping.packageFqName2Parts) {
appendln(fqName)
for (part in packageParts.parts) {
@@ -88,4 +92,17 @@ class JvmModuleProtoBufTest : KtUsefulTestCase() {
doTest("/moduleProtoBuf/jvmPackageNameLanguageVersion11",
compileWith = LanguageVersion.KOTLIN_1_2, loadWith = LanguageVersion.KOTLIN_1_1)
}
fun testExperimental() {
doTest(
"/moduleProtoBuf/experimental", extraOptions = listOf(
"-Xskip-runtime-version-check",
"-language-version",
"1.3",
"-Xexperimental=org.foo.A",
"-Xexperimental=org.foo.B.C",
"-Xuse-experimental=org.foo.D"
)
)
}
}