Skip to content

Commit 7471f03

Browse files
ddolovovSpace Team
authored andcommitted
[Test] Add test directives to enable/disable nested IR element offsets checks
^KT-81475
1 parent 50cf771 commit 7471f03

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

compiler/tests-common-new/testFixtures/org/jetbrains/kotlin/test/directives/CodegenTestDirectives.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,15 @@ object CodegenTestDirectives : SimpleDirectivesContainer() {
245245
applicability = Global
246246
)
247247

248+
// TODO: Drop this directive and make the offset validation enabled by default when KT-81475 is fixed.
249+
val ENABLE_IR_NESTED_OFFSETS_CHECKS by stringDirective(
250+
description = "Enables validation of the nested IR elements offsets"
251+
)
252+
253+
val DISABLE_IR_NESTED_OFFSETS_CHECKS by enumDirective<TargetBackend>(
254+
description = "Disabled validation of the nested IR elements offsets on the target backend"
255+
)
256+
248257
val DISABLE_IR_VISIBILITY_CHECKS by enumDirective<TargetBackend>(
249258
description = "Don't check for visibility violations when validating IR on the target backend"
250259
)

compiler/tests-common-new/testFixtures/org/jetbrains/kotlin/test/services/CompilerConfigurationProvider.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ fun createCompilerConfiguration(
180180
configuration.enableIrVisibilityChecks = !CodegenTestDirectives.DISABLE_IR_VISIBILITY_CHECKS.isApplicableTo(module, testServices)
181181
configuration.enableIrVarargTypesChecks = !CodegenTestDirectives.DISABLE_IR_VARARG_TYPE_CHECKS.isApplicableTo(module, testServices)
182182

183+
configuration.enableIrNestedOffsetsChecks = CodegenTestDirectives.ENABLE_IR_NESTED_OFFSETS_CHECKS in module.directives &&
184+
!CodegenTestDirectives.DISABLE_IR_NESTED_OFFSETS_CHECKS.isApplicableTo(module, testServices)
185+
183186
val messageCollector = MessageCollectorForCompilerTests(System.err, CompilerTestMessageRenderer(module))
184187
configuration.messageCollector = messageCollector
185188
configuration.languageVersionSettings = module.languageVersionSettings

native/native.tests/testFixtures/org/jetbrains/kotlin/konan/test/blackbox/support/group/ExtTestCaseGroupProvider.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,9 @@ import org.jetbrains.kotlin.test.InTextDirectivesUtils.isDirectiveDefined
4848
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives
4949
import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives.RETURN_VALUE_CHECKER_MODE
5050
import org.jetbrains.kotlin.test.directives.model.RegisteredDirectives
51-
import org.jetbrains.kotlin.test.frontend.classic.handlers.ClassicUnstableAndK2LanguageFeaturesSkipConfigurator
5251
import org.jetbrains.kotlin.test.services.JUnit5Assertions.assertFalse
5352
import org.jetbrains.kotlin.test.services.JUnit5Assertions.assertTrue
5453
import org.jetbrains.kotlin.test.services.JUnit5Assertions.fail
55-
import org.jetbrains.kotlin.test.util.parseLanguageFeature
5654
import org.jetbrains.kotlin.utils.addIfNotNull
5755
import java.io.File
5856

@@ -196,6 +194,15 @@ private class ExtTestDataFile(
196194
) {
197195
args.add("-Xverify-ir-visibility")
198196
}
197+
198+
if ((structure.directives.contains(CodegenTestDirectives.ENABLE_IR_NESTED_OFFSETS_CHECKS) ||
199+
defaultDirectives.contains(CodegenTestDirectives.ENABLE_IR_NESTED_OFFSETS_CHECKS)) &&
200+
!structure.directives[CodegenTestDirectives.DISABLE_IR_NESTED_OFFSETS_CHECKS].containsNativeOrAny &&
201+
!defaultDirectives[CodegenTestDirectives.DISABLE_IR_NESTED_OFFSETS_CHECKS].containsNativeOrAny
202+
) {
203+
args.add("-Xverify-ir-nested-offsets")
204+
}
205+
199206
args += "-opt-in=kotlin.native.internal.InternalForKotlinNative" // for `Any.isPermanent()` and `Any.isStack()`
200207
args += "-opt-in=kotlin.native.internal.InternalForKotlinNativeTests" // for ReflectionPackageName
201208
if (!settings.withPlatformLibs && !structure.directives.contains(WITH_PLATFORM_LIBS))

0 commit comments

Comments
 (0)