diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/InTextDirectivesUtils.java b/compiler/tests-common/tests/org/jetbrains/kotlin/test/InTextDirectivesUtils.java index ddf800a4752..5210d71809b 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/InTextDirectivesUtils.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/InTextDirectivesUtils.java @@ -233,12 +233,13 @@ public final class InTextDirectivesUtils { return ignoredBackends.contains(targetBackend.name()); } - public static boolean isIgnoredTargetWithoutCheck(TargetBackend targetBackend, File file) { - return isIgnoredTargetByPrefix(targetBackend, file, "// IGNORE_BACKEND_WITHOUT_CHECK: "); + public static boolean dontRunGeneratedCode(TargetBackend targetBackend, File file) { + List backends = findListWithPrefixes(textWithDirectives(file), "// DONT_RUN_GENERATED_CODE: "); + return backends.contains(targetBackend.name()); } // Whether the target test is supposed to pass successfully on targetBackend public static boolean isPassingTarget(TargetBackend targetBackend, File file) { - return isCompatibleTarget(targetBackend, file) && !isIgnoredTarget(targetBackend, file) && !isIgnoredTargetWithoutCheck(targetBackend, file); + return isCompatibleTarget(targetBackend, file) && !isIgnoredTarget(targetBackend, file); } } diff --git a/generators/test-generator/tests/org/jetbrains/kotlin/generators/tests/generator/SimpleTestMethodModel.java b/generators/test-generator/tests/org/jetbrains/kotlin/generators/tests/generator/SimpleTestMethodModel.java index 2d83f50d162..69359d7e8ef 100644 --- a/generators/test-generator/tests/org/jetbrains/kotlin/generators/tests/generator/SimpleTestMethodModel.java +++ b/generators/test-generator/tests/org/jetbrains/kotlin/generators/tests/generator/SimpleTestMethodModel.java @@ -19,7 +19,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import static org.jetbrains.kotlin.test.InTextDirectivesUtils.isIgnoredTarget; -import static org.jetbrains.kotlin.test.InTextDirectivesUtils.isIgnoredTargetWithoutCheck; public class SimpleTestMethodModel implements TestMethodModel { @@ -96,8 +95,7 @@ public class SimpleTestMethodModel implements TestMethodModel { unescapedName = relativePath + "-" + StringsKt.capitalize(extractedName); } - boolean ignored = isIgnoredTargetWithoutCheck(targetBackend, file) || - skipIgnored && isIgnoredTarget(targetBackend, file); + boolean ignored = skipIgnored && isIgnoredTarget(targetBackend, file); return (ignored ? "ignore" : "test") + StringsKt.capitalize(TestGeneratorUtil.escapeForJavaIdentifier(unescapedName)); } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt index 91754638873..4217bbdbead 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt @@ -72,7 +72,8 @@ abstract class BasicBoxTest( pathToRootOutputDir: String = BasicBoxTest.TEST_DATA_DIR_PATH, private val typedArraysEnabled: Boolean = true, private val generateSourceMap: Boolean = false, - private val generateNodeJsRunner: Boolean = true + private val generateNodeJsRunner: Boolean = true, + private val targetBackend: TargetBackend = TargetBackend.JS ) : KotlinTestWithEnvironment() { val additionalCommonFileDirectories = mutableListOf() @@ -161,14 +162,18 @@ abstract class BasicBoxTest( val allJsFiles = additionalFiles + inputJsFiles + generatedJsFiles.map { it.first } + globalCommonFiles + localCommonFiles + additionalCommonFiles - if (generateNodeJsRunner && !SKIP_NODE_JS.matcher(fileContent).find()) { + val dontRunGeneratedCode = InTextDirectivesUtils.dontRunGeneratedCode(targetBackend, file) + + if (!dontRunGeneratedCode && generateNodeJsRunner && !SKIP_NODE_JS.matcher(fileContent).find()) { val nodeRunnerName = mainModule.outputFileName(outputDir) + ".node.js" val ignored = InTextDirectivesUtils.isIgnoredTarget(TargetBackend.JS, file) val nodeRunnerText = generateNodeRunner(allJsFiles, outputDir, mainModuleName, ignored, testPackage) FileUtil.writeToFile(File(nodeRunnerName), nodeRunnerText) } - runGeneratedCode(allJsFiles, mainModuleName, testPackage, testFunction, expectedResult, withModuleSystem) + if (!dontRunGeneratedCode) { + runGeneratedCode(allJsFiles, mainModuleName, testPackage, testFunction, expectedResult, withModuleSystem) + } performAdditionalChecks(generatedJsFiles.map { it.first }, outputPrefixFile, outputPostfixFile) @@ -202,16 +207,19 @@ abstract class BasicBoxTest( } val outputDirForMinification = getOutputDir(file, testGroupOutputDirForMinification) - minifyAndRun( - workDir = File(outputDirForMinification, file.nameWithoutExtension), - allJsFiles = allJsFiles, - generatedJsFiles = generatedJsFiles, - expectedResult = expectedResult, - testModuleName = mainModuleName, - testPackage = testPackage, - testFunction = testFunction, - withModuleSystem = withModuleSystem, - minificationThresholdChecker = thresholdChecker) + + if (!dontRunGeneratedCode) { + minifyAndRun( + workDir = File(outputDirForMinification, file.nameWithoutExtension), + allJsFiles = allJsFiles, + generatedJsFiles = generatedJsFiles, + expectedResult = expectedResult, + testModuleName = mainModuleName, + testPackage = testPackage, + testFunction = testFunction, + withModuleSystem = withModuleSystem, + minificationThresholdChecker = thresholdChecker) + } } } } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicIrBoxTest.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicIrBoxTest.kt index 7384d184e34..6f9e19c7471 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicIrBoxTest.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicIrBoxTest.kt @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.js.config.JsConfig import org.jetbrains.kotlin.js.facade.MainCallParameters import org.jetbrains.kotlin.js.facade.TranslationUnit import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.test.TargetBackend import java.io.File abstract class BasicIrBoxTest( @@ -18,7 +19,15 @@ abstract class BasicIrBoxTest( pathToRootOutputDir: String = BasicBoxTest.TEST_DATA_DIR_PATH, generateSourceMap: Boolean = false, generateNodeJsRunner: Boolean = false -) : BasicBoxTest(pathToTestDir, testGroupOutputDirPrefix, pathToRootOutputDir, true, generateSourceMap, generateNodeJsRunner) { +) : BasicBoxTest( + pathToTestDir, + testGroupOutputDirPrefix, + pathToRootOutputDir = pathToRootOutputDir, + typedArraysEnabled = true, + generateSourceMap = generateSourceMap, + generateNodeJsRunner = generateNodeJsRunner, + targetBackend = TargetBackend.JS_IR +) { override var skipMinification = true