bcv: cleanup the old way of reading kotlin visibilities
This commit is contained in:
+10
-6
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.tools.tests
|
||||
|
||||
import org.jetbrains.kotlin.tools.*
|
||||
@@ -8,12 +13,11 @@ import java.io.File
|
||||
class CasesPublicAPITest {
|
||||
|
||||
companion object {
|
||||
val visibilities by lazy { readKotlinVisibilities(File(System.getProperty("testCasesDeclarations")!!)) }
|
||||
val baseClassPaths: List<File> =
|
||||
System.getProperty("testCasesClassesDirs")
|
||||
.let { requireNotNull(it) { "Specify testCasesClassesDirs with a system property"} }
|
||||
.split(File.pathSeparator)
|
||||
.map { File(it, "cases").canonicalFile }
|
||||
System.getProperty("testCasesClassesDirs")
|
||||
.let { requireNotNull(it) { "Specify testCasesClassesDirs with a system property"} }
|
||||
.split(File.pathSeparator)
|
||||
.map { File(it, "cases").canonicalFile }
|
||||
val baseOutputPath = File("src/test/kotlin/cases")
|
||||
}
|
||||
|
||||
@@ -54,7 +58,7 @@ class CasesPublicAPITest {
|
||||
|
||||
val testClassStreams = testClasses.asSequence().filter { it.name.endsWith(".class") }.map { it.inputStream() }
|
||||
|
||||
val api = getBinaryAPI(testClassStreams, visibilities).filterOutNonPublic()
|
||||
val api = getBinaryAPI(testClassStreams).filterOutNonPublic()
|
||||
|
||||
val target = baseOutputPath.resolve(testClassRelativePath).resolve(testName.methodName + ".txt")
|
||||
|
||||
|
||||
+19
-35
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.tools.tests
|
||||
@@ -29,56 +18,51 @@ class RuntimePublicAPITest {
|
||||
val testName = TestName()
|
||||
|
||||
@Test fun kotlinRuntime() {
|
||||
snapshotAPIAndCompare("../../stdlib/runtime/build/libs", "kotlin-runtime", listOf("../runtime-declarations.json"), listOf("kotlin.jvm.internal"))
|
||||
snapshotAPIAndCompare("../../stdlib/runtime/build/libs", "kotlin-runtime", listOf("kotlin.jvm.internal"))
|
||||
}
|
||||
|
||||
@Test fun kotlinStdlibRuntimeMerged() {
|
||||
snapshotAPIAndCompare(
|
||||
"../../stdlib/jvm/build/libs", "kotlin-stdlib",
|
||||
listOf("../stdlib-declarations.json"/*, "../stdlib-experimental-declarations.json"*/),
|
||||
listOf("kotlin.jvm.internal")
|
||||
)
|
||||
snapshotAPIAndCompare("../../stdlib/jvm/build/libs", "kotlin-stdlib", listOf("kotlin.jvm.internal"))
|
||||
}
|
||||
|
||||
@Test fun kotlinStdlibJdk7() {
|
||||
snapshotAPIAndCompare("../../stdlib/jdk7/build/libs", "kotlin-stdlib-jdk7", listOf("../stdlib-jdk7-declarations.json"))
|
||||
snapshotAPIAndCompare("../../stdlib/jdk7/build/libs", "kotlin-stdlib-jdk7")
|
||||
}
|
||||
|
||||
@Test fun kotlinStdlibJdk8() {
|
||||
snapshotAPIAndCompare("../../stdlib/jdk8/build/libs", "kotlin-stdlib-jdk8", listOf("../stdlib-jdk8-declarations.json"))
|
||||
snapshotAPIAndCompare("../../stdlib/jdk8/build/libs", "kotlin-stdlib-jdk8")
|
||||
}
|
||||
|
||||
@Test fun kotlinStdlibJre7() {
|
||||
snapshotAPIAndCompare("../../stdlib/jre7/build/libs", "kotlin-stdlib-jre7", listOf("../stdlib-jre7-declarations.json"))
|
||||
snapshotAPIAndCompare("../../stdlib/jre7/build/libs", "kotlin-stdlib-jre7")
|
||||
}
|
||||
|
||||
@Test fun kotlinStdlibJre8() {
|
||||
snapshotAPIAndCompare("../../stdlib/jre8/build/libs", "kotlin-stdlib-jre8", listOf("../stdlib-jre8-declarations.json"))
|
||||
snapshotAPIAndCompare("../../stdlib/jre8/build/libs", "kotlin-stdlib-jre8")
|
||||
}
|
||||
|
||||
@Test fun kotlinReflect() {
|
||||
snapshotAPIAndCompare("../../reflect/api/build/libs", "kotlin-reflect-api(?!-[-a-z]+)", listOf("../reflect-declarations.json"), nonPublicPackages = listOf("kotlin.reflect.jvm.internal"))
|
||||
snapshotAPIAndCompare("../../reflect/api/build/libs", "kotlin-reflect-api(?!-[-a-z]+)", nonPublicPackages = listOf("kotlin.reflect.jvm.internal"))
|
||||
}
|
||||
|
||||
|
||||
private fun snapshotAPIAndCompare(basePath: String, jarPattern: String, kotlinJvmMappingsPath: List<String>, publicPackages: List<String> = emptyList(), nonPublicPackages: List<String> = emptyList()) {
|
||||
private fun snapshotAPIAndCompare(
|
||||
basePath: String,
|
||||
jarPattern: String,
|
||||
publicPackages: List<String> = emptyList(),
|
||||
nonPublicPackages: List<String> = emptyList()
|
||||
) {
|
||||
val base = File(basePath).absoluteFile.normalize()
|
||||
val jarFile = getJarPath(base, jarPattern, System.getProperty("kotlinVersion"))
|
||||
val kotlinJvmMappingsFiles = kotlinJvmMappingsPath.map(base::resolve)
|
||||
|
||||
println("Reading kotlin visibilities from $kotlinJvmMappingsFiles")
|
||||
val publicPackagePrefixes = publicPackages.map { it.replace('.', '/') + '/' }
|
||||
val publicPackageFilter = { className: String -> publicPackagePrefixes.none { className.startsWith(it) } }
|
||||
val visibilities =
|
||||
kotlinJvmMappingsFiles
|
||||
.map { readKotlinVisibilities(it).filterKeys(publicPackageFilter) }
|
||||
.reduce { m1, m2 -> m1 + m2 }
|
||||
|
||||
println("Reading binary API from $jarFile")
|
||||
val api = getBinaryAPI(JarFile(jarFile), visibilities, publicPackageFilter).filterOutNonPublic(nonPublicPackages)
|
||||
val api = getBinaryAPI(JarFile(jarFile), publicPackageFilter).filterOutNonPublic(nonPublicPackages)
|
||||
|
||||
val target = File("reference-public-api")
|
||||
.resolve(testName.methodName.replaceCamelCaseWithDashedLowerCase() + ".txt")
|
||||
.resolve(testName.methodName.replaceCamelCaseWithDashedLowerCase() + ".txt")
|
||||
|
||||
api.dumpAndCompareWith(target)
|
||||
}
|
||||
@@ -89,8 +73,8 @@ class RuntimePublicAPITest {
|
||||
val files = (base.listFiles() ?: throw Exception("Cannot list files in $base"))
|
||||
.filter { it.name.let {
|
||||
it matches regex
|
||||
&& !it.endsWith("-sources.jar")
|
||||
&& !it.endsWith("-javadoc.jar") } }
|
||||
&& !it.endsWith("-sources.jar")
|
||||
&& !it.endsWith("-javadoc.jar") } }
|
||||
|
||||
return files.singleOrNull() ?: throw Exception("No single file matching $regex in $base:\n${files.joinToString("\n")}")
|
||||
}
|
||||
|
||||
+5
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.tools.tests
|
||||
|
||||
import org.jetbrains.kotlin.tools.*
|
||||
|
||||
Reference in New Issue
Block a user