Kotlinp: add "test can be unmuted" error to K2 tests
This commit is contained in:
committed by
Space Team
parent
3366366361
commit
1be0fcb53a
+1
-1
@@ -12,7 +12,7 @@ abstract class AbstractKotlinpTest : TestCaseWithTmpdir() {
|
|||||||
abstract fun useK2(): Boolean
|
abstract fun useK2(): Boolean
|
||||||
|
|
||||||
protected fun doTest(fileName: String) {
|
protected fun doTest(fileName: String) {
|
||||||
compileAndPrintAllFiles(
|
compareAllFiles(
|
||||||
File(fileName),
|
File(fileName),
|
||||||
testRootDisposable,
|
testRootDisposable,
|
||||||
tmpdir,
|
tmpdir,
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@ class KotlinpCompilerTestDataTest(private val file: File) {
|
|||||||
|
|
||||||
val disposable = TestDisposable()
|
val disposable = TestDisposable()
|
||||||
try {
|
try {
|
||||||
compileAndPrintAllFiles(file, disposable, tmpdir, compareWithTxt = false, readWriteAndCompare = true, useK2 = false)
|
compareAllFiles(file, disposable, tmpdir, compareWithTxt = false, readWriteAndCompare = true, useK2 = false)
|
||||||
} finally {
|
} finally {
|
||||||
Disposer.dispose(disposable)
|
Disposer.dispose(disposable)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ import org.jetbrains.kotlin.checkers.setupLanguageVersionSettingsForCompilerTest
|
|||||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||||
import org.jetbrains.kotlin.codegen.GenerationUtils
|
import org.jetbrains.kotlin.codegen.GenerationUtils
|
||||||
import org.jetbrains.kotlin.config.*
|
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||||
|
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||||
import org.jetbrains.kotlin.jvm.compiler.AbstractLoadJavaTest
|
import org.jetbrains.kotlin.jvm.compiler.AbstractLoadJavaTest
|
||||||
import org.jetbrains.kotlin.kotlinp.Kotlinp
|
import org.jetbrains.kotlin.kotlinp.Kotlinp
|
||||||
import org.jetbrains.kotlin.kotlinp.KotlinpSettings
|
import org.jetbrains.kotlin.kotlinp.KotlinpSettings
|
||||||
@@ -26,18 +27,36 @@ import org.jetbrains.kotlin.test.util.KtTestUtil
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.test.fail
|
import kotlin.test.fail
|
||||||
|
|
||||||
fun compileAndPrintAllFiles(
|
private const val IGNORE_K2_DIRECTIVE = "// IGNORE K2"
|
||||||
|
|
||||||
|
fun compareAllFiles(
|
||||||
file: File,
|
file: File,
|
||||||
disposable: Disposable,
|
disposable: Disposable,
|
||||||
tmpdir: File,
|
tmpdir: File,
|
||||||
compareWithTxt: Boolean,
|
compareWithTxt: Boolean,
|
||||||
readWriteAndCompare: Boolean,
|
readWriteAndCompare: Boolean,
|
||||||
useK2: Boolean
|
useK2: Boolean,
|
||||||
) {
|
) {
|
||||||
if (useK2 && InTextDirectivesUtils.findStringWithPrefixes(file.readText(), "// IGNORE K2") != null) {
|
val isMutedForK2 = useK2 && InTextDirectivesUtils.findStringWithPrefixes(file.readText(), IGNORE_K2_DIRECTIVE) != null
|
||||||
return
|
try {
|
||||||
|
compileAndPrintAllFiles(file, disposable, tmpdir, compareWithTxt, readWriteAndCompare, useK2)
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
if (isMutedForK2) return
|
||||||
|
throw e
|
||||||
}
|
}
|
||||||
|
if (isMutedForK2) {
|
||||||
|
throw AssertionError("Looks like this test can be unmuted. Remove the \"$IGNORE_K2_DIRECTIVE\" directive.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun compileAndPrintAllFiles(
|
||||||
|
file: File,
|
||||||
|
disposable: Disposable,
|
||||||
|
tmpdir: File,
|
||||||
|
compareWithTxt: Boolean,
|
||||||
|
readWriteAndCompare: Boolean,
|
||||||
|
useK2: Boolean,
|
||||||
|
) {
|
||||||
val main = StringBuilder()
|
val main = StringBuilder()
|
||||||
val afterVisitors = StringBuilder()
|
val afterVisitors = StringBuilder()
|
||||||
val afterNodes = StringBuilder()
|
val afterNodes = StringBuilder()
|
||||||
|
|||||||
Reference in New Issue
Block a user