Report pre-release errors if release LV is used

#KT-21267 Fixed
This commit is contained in:
Alexander Udalov
2017-11-15 12:50:23 +01:00
parent 64a8008a8a
commit d386712903
15 changed files with 80 additions and 26 deletions
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.codegen.inline.remove
import org.jetbrains.kotlin.codegen.optimization.common.asSequence
import org.jetbrains.kotlin.codegen.optimization.common.intConstant
import org.jetbrains.kotlin.config.KotlinCompilerVersion.TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY
import org.jetbrains.kotlin.config.LanguageVersion
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.PackageViewDescriptor
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
@@ -131,27 +132,28 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
) {
// Compiles the library with the "pre-release" flag, then compiles a usage of this library in the release mode
val result = try {
System.setProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY, "true")
val result = withPreRelease(true) {
when (compiler) {
is K2JSCompiler -> compileJsLibrary(libraryName)
is K2JVMCompiler -> compileLibrary(libraryName)
else -> throw UnsupportedOperationException(compiler.toString())
}
}
finally {
System.clearProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY)
}
try {
System.setProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY, "false")
withPreRelease(false) {
compileKotlin("source.kt", usageDestination, listOf(result), compiler, additionalOptions.toList())
}
finally {
System.clearProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY)
}
}
private fun <T> withPreRelease(value: Boolean, block: () -> T): T =
try {
System.setProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY, value.toString())
block()
}
finally {
System.clearProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY)
}
// ------------------------------------------------------------------------------
fun testRawTypes() {
@@ -258,6 +260,23 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
doTestPreReleaseKotlinLibrary(K2JSCompiler(), "library", File(tmpdir, "usage.js"), "-Xskip-metadata-version-check")
}
fun testPreReleaseCompilerAgainstPreReleaseLibraryStableLanguageVersion() {
withPreRelease(true) {
val library = compileLibrary("library")
val someStableReleasedVersion = LanguageVersion.values().first().also { assert(it.isStable) }
compileKotlin("source.kt", tmpdir, listOf(library), K2JVMCompiler(),
listOf("-language-version", someStableReleasedVersion.versionString))
}
}
fun testPreReleaseCompilerAgainstPreReleaseLibraryLatestStable() {
withPreRelease(true) {
val library = compileLibrary("library")
compileKotlin("source.kt", tmpdir, listOf(library), K2JVMCompiler(),
listOf("-language-version", LanguageVersion.LATEST_STABLE.versionString))
}
}
fun testWrongMetadataVersion() {
doTestKotlinLibraryWithWrongMetadataVersion("library", null)
}