Add CLI tests on internal from other module (JVM, JS, common)
This commit is contained in:
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
package a
|
||||
|
||||
internal interface InternalInterface
|
||||
|
||||
public class PublicClass {
|
||||
internal fun internalMemberFun() {}
|
||||
|
||||
internal companion object {}
|
||||
}
|
||||
|
||||
internal val internalVal = ""
|
||||
|
||||
internal fun internalFun(s: String): String = s
|
||||
|
||||
internal typealias InternalTypealias = InternalInterface
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/internalFromForeignModuleCommon/source.kt:3:21: error: cannot access 'InternalInterface': it is internal in 'a'
|
||||
private fun test(i: InternalInterface): InternalTypealias {
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/internalFromForeignModuleCommon/source.kt:3:41: error: cannot access 'InternalTypealias': it is internal in 'a'
|
||||
private fun test(i: InternalInterface): InternalTypealias {
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/internalFromForeignModuleCommon/source.kt:4:19: error: cannot access 'internalMemberFun': it is internal in 'PublicClass'
|
||||
PublicClass().internalMemberFun()
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/internalFromForeignModuleCommon/source.kt:5:17: error: cannot access 'Companion': it is internal in 'PublicClass'
|
||||
PublicClass.Companion
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/internalFromForeignModuleCommon/source.kt:7:5: error: cannot access 'internalFun': it is internal in 'a'
|
||||
internalFun(internalVal)
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/internalFromForeignModuleCommon/source.kt:7:17: error: cannot access 'internalVal': it is internal in 'a'
|
||||
internalFun(internalVal)
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
import a.*
|
||||
|
||||
private fun test(i: InternalInterface): InternalTypealias {
|
||||
PublicClass().internalMemberFun()
|
||||
PublicClass.Companion
|
||||
|
||||
internalFun(internalVal)
|
||||
|
||||
return i
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
package a
|
||||
|
||||
internal interface InternalInterface
|
||||
|
||||
public class PublicClass {
|
||||
internal fun internalMemberFun() {}
|
||||
|
||||
internal companion object {}
|
||||
}
|
||||
|
||||
internal val internalVal = ""
|
||||
|
||||
internal fun internalFun(s: String): String = s
|
||||
|
||||
internal typealias InternalTypealias = InternalInterface
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/internalFromForeignModuleJs/source.kt:3:21: error: cannot access 'InternalInterface': it is internal in 'a'
|
||||
private fun test(i: InternalInterface): InternalTypealias {
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/internalFromForeignModuleJs/source.kt:3:41: error: cannot access 'InternalTypealias': it is internal in 'a'
|
||||
private fun test(i: InternalInterface): InternalTypealias {
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/internalFromForeignModuleJs/source.kt:4:19: error: cannot access 'internalMemberFun': it is internal in 'PublicClass'
|
||||
PublicClass().internalMemberFun()
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/internalFromForeignModuleJs/source.kt:5:17: error: cannot access 'Companion': it is internal in 'PublicClass'
|
||||
PublicClass.Companion
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/internalFromForeignModuleJs/source.kt:7:5: error: cannot access 'internalFun': it is internal in 'a'
|
||||
internalFun(internalVal)
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/internalFromForeignModuleJs/source.kt:7:17: error: cannot access 'internalVal': it is internal in 'a'
|
||||
internalFun(internalVal)
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import a.*
|
||||
|
||||
private fun test(i: InternalInterface): InternalTypealias {
|
||||
PublicClass().internalMemberFun()
|
||||
PublicClass.Companion
|
||||
|
||||
internalFun(internalVal)
|
||||
|
||||
return i
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
package a
|
||||
|
||||
internal interface InternalInterface
|
||||
|
||||
public class PublicClass {
|
||||
internal fun internalMemberFun() {}
|
||||
|
||||
internal companion object {}
|
||||
}
|
||||
|
||||
internal val internalVal = ""
|
||||
|
||||
internal fun internalFun(s: String): String = s
|
||||
|
||||
internal typealias InternalTypealias = InternalInterface
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
OK
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
import a.*
|
||||
|
||||
private fun test(i: InternalInterface): InternalTypealias {
|
||||
PublicClass().internalMemberFun()
|
||||
PublicClass.Companion
|
||||
|
||||
internalFun(internalVal)
|
||||
|
||||
return i
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
package a
|
||||
|
||||
internal interface InternalInterface
|
||||
|
||||
public class PublicClass {
|
||||
internal fun internalMemberFun() {}
|
||||
|
||||
internal companion object {}
|
||||
}
|
||||
|
||||
internal val internalVal = ""
|
||||
|
||||
internal fun internalFun(s: String): String = s
|
||||
|
||||
internal typealias InternalTypealias = InternalInterface
|
||||
+1
@@ -0,0 +1 @@
|
||||
OK
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import a.*
|
||||
|
||||
private fun test(i: InternalInterface): InternalTypealias {
|
||||
PublicClass().internalMemberFun()
|
||||
PublicClass.Companion
|
||||
|
||||
internalFun(internalVal)
|
||||
|
||||
return i
|
||||
}
|
||||
+21
-4
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.cli.common.CLICompiler
|
||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||
import org.jetbrains.kotlin.cli.js.K2JSCompiler
|
||||
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
|
||||
import org.jetbrains.kotlin.cli.metadata.K2MetadataCompiler
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.TestCaseWithTmpdir
|
||||
import java.io.File
|
||||
@@ -112,6 +113,24 @@ abstract class AbstractKotlinCompilerIntegrationTest : TestCaseWithTmpdir() {
|
||||
return File(tmpdir, "$libraryName.meta.js")
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles all .kt sources under the directory named [libraryName] to a directory named "[libraryName]" in [tmpdir]
|
||||
*
|
||||
* @return the path to the corresponding directory
|
||||
*/
|
||||
protected fun compileCommonLibrary(
|
||||
libraryName: String,
|
||||
additionalOptions: List<String> = emptyList(),
|
||||
checkKotlinOutput: (String) -> Unit = { actual -> assertEquals(normalizeOutput("" to ExitCode.OK), actual) }
|
||||
): File {
|
||||
val destination = File(tmpdir, libraryName)
|
||||
val output = compileKotlin(
|
||||
libraryName, destination, compiler = K2MetadataCompiler(), additionalOptions = additionalOptions, expectedFileName = null
|
||||
)
|
||||
checkKotlinOutput(normalizeOutput(output))
|
||||
return destination
|
||||
}
|
||||
|
||||
private fun normalizeOutput(output: Pair<String, ExitCode>): String {
|
||||
return AbstractCliTest.getNormalizedCompilerOutput(output.first, output.second, testDataDirectory.path)
|
||||
.replace(FileUtil.toSystemIndependentName(tmpdir.absolutePath), "\$TMP_DIR\$")
|
||||
@@ -138,16 +157,14 @@ abstract class AbstractKotlinCompilerIntegrationTest : TestCaseWithTmpdir() {
|
||||
args.add("-output")
|
||||
args.add(output.path)
|
||||
args.add("-meta-info")
|
||||
}
|
||||
else if (compiler is K2JVMCompiler) {
|
||||
} else if (compiler is K2JVMCompiler || compiler is K2MetadataCompiler) {
|
||||
if (classpath.isNotEmpty()) {
|
||||
args.add("-classpath")
|
||||
args.add(classpath.joinToString(File.pathSeparator))
|
||||
}
|
||||
args.add("-d")
|
||||
args.add(output.path)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw UnsupportedOperationException(compiler.toString())
|
||||
}
|
||||
|
||||
|
||||
+24
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.cli.js.K2JSCompiler
|
||||
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.cli.metadata.K2MetadataCompiler
|
||||
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
|
||||
import org.jetbrains.kotlin.codegen.inline.GENERATE_SMAP
|
||||
import org.jetbrains.kotlin.codegen.inline.remove
|
||||
@@ -480,6 +481,29 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
|
||||
compileKotlin("source.kt", tmpdir, listOf(library), additionalOptions = listOf("-Xfriend-paths=${library.path}"))
|
||||
}
|
||||
|
||||
fun testInternalFromForeignModuleJs() {
|
||||
compileKotlin("source.kt", File(tmpdir, "usage.js"), listOf(compileJsLibrary("library")), K2JSCompiler())
|
||||
}
|
||||
|
||||
fun testInternalFromFriendModuleJs() {
|
||||
val library = compileJsLibrary("library")
|
||||
compileKotlin("source.kt", File(tmpdir, "usage.js"), listOf(library), K2JSCompiler(), listOf("-Xfriend-modules=${library.path}"))
|
||||
}
|
||||
|
||||
/*
|
||||
// TODO: see KT-15661 and KT-23483
|
||||
fun testInternalFromForeignModuleCommon() {
|
||||
compileKotlin("source.kt", tmpdir, listOf(compileCommonLibrary("library")), K2MetadataCompiler())
|
||||
}
|
||||
*/
|
||||
|
||||
fun testInternalFromFriendModuleCommon() {
|
||||
val library = compileCommonLibrary("library")
|
||||
compileKotlin("source.kt", tmpdir, listOf(library), K2MetadataCompiler(), listOf(
|
||||
// TODO: "-Xfriend-paths=${library.path}"
|
||||
))
|
||||
}
|
||||
|
||||
companion object {
|
||||
// compiler before 1.1.4 version did not include suspension marks into bytecode.
|
||||
private fun stripSuspensionMarksToImitateLegacyCompiler(bytes: ByteArray): Pair<ByteArray, Int> {
|
||||
|
||||
Reference in New Issue
Block a user