From 02bdc826d5be109bca7aae118018c711b31ffe30 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 8 Apr 2019 17:50:16 +0300 Subject: [PATCH] IR text tests: throw an error when test fails to build an external dump --- .../org/jetbrains/kotlin/ir/AbstractIrTextTestCase.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrTextTestCase.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrTextTestCase.kt index 27d09479d49..61974812292 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrTextTestCase.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrTextTestCase.kt @@ -32,6 +32,7 @@ import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.test.KotlinTestUtils +import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase import org.jetbrains.kotlin.utils.rethrow import java.io.File import java.util.regex.Pattern @@ -59,11 +60,19 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() { myEnvironment.configuration.languageVersionSettings ) + val path = wholeFile.path + val replacedPath = path.replace(".kt", "__") + val externalFilePaths = wholeFile.parentFile.listFiles().mapNotNullTo(mutableListOf()) { + if (it.path.startsWith(replacedPath)) it.path else null + } for (externalClassFqn in parseDumpExternalClasses(wholeText)) { val classDump = stubGenerator.generateExternalClass(irModule.descriptor, externalClassFqn).dump() - val expectedFile = File(wholeFile.path.replace(".kt", "__$externalClassFqn.txt")) + val expectedFilePath = path.replace(".kt", "__$externalClassFqn.txt") + val expectedFile = File(expectedFilePath) + externalFilePaths -= expectedFilePath KotlinTestUtils.assertEqualsToFile(expectedFile, classDump) } + KtUsefulTestCase.assertEmpty("The following external dump files were not built: $externalFilePaths", externalFilePaths) } private fun DeclarationStubGenerator.generateExternalClass(descriptor: ModuleDescriptor, externalClassFqn: String): IrClass {