From 910718ff4509e299ad53ccb5361e30ff2617ec16 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Tue, 3 Nov 2015 18:14:18 +0300 Subject: [PATCH] Weaken JvmRuntimeDescriptorLoaderTest assumptions Sometimes descriptors in reflection may differ from compiled ones. There is already SKIP_IN_RUNTIME_TEST but sometimes it would be nice to record specific behaviour. Solution is to add '.runtime.txt' near '.txt' files for tests containing expected rendered descriptors in reflection. --- .../AbstractJvmRuntimeDescriptorLoaderTest.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/runtime/AbstractJvmRuntimeDescriptorLoaderTest.kt b/compiler/tests/org/jetbrains/kotlin/jvm/runtime/AbstractJvmRuntimeDescriptorLoaderTest.kt index 980be8b7a6f..21a342eda77 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/runtime/AbstractJvmRuntimeDescriptorLoaderTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/jvm/runtime/AbstractJvmRuntimeDescriptorLoaderTest.kt @@ -88,10 +88,6 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi val actual = createReflectedPackageView(classLoader, JvmResolveUtil.TEST_MODULE_NAME) - val expected = LoadDescriptorUtil.loadTestPackageAndBindingContextFromJavaRoot( - tmpdir, getTestRootDisposable(), jdkKind, ConfigurationKind.ALL, true - ).first - val comparatorConfiguration = Configuration( /* checkPrimaryConstructors = */ fileName.endsWith(".kt"), /* checkPropertyAccessors = */ true, @@ -100,6 +96,17 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi { descriptor -> !descriptor.isJavaAnnotationConstructor() }, errorTypesForbidden(), renderer ) + + val differentResultFile = KotlinTestUtils.replaceExtension(file, "runtime.txt") + if (differentResultFile.exists()) { + RecursiveDescriptorComparator.validateAndCompareDescriptorWithFile(actual, comparatorConfiguration, differentResultFile) + return + } + + val expected = LoadDescriptorUtil.loadTestPackageAndBindingContextFromJavaRoot( + tmpdir, getTestRootDisposable(), jdkKind, ConfigurationKind.ALL, true + ).first + RecursiveDescriptorComparator.validateAndCompareDescriptors(expected, actual, comparatorConfiguration, null) } @@ -144,7 +151,6 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi val packageScopes = arrayListOf() val classes = arrayListOf() - var shouldAddPackageView = false for (classFile in allClassFiles) { val className = classFile.relativeTo(tmpdir).substringBeforeLast(".class").replace('/', '.').replace('\\', '.')