Remove IGNORE_BACKEND_WITHOUT_CHECK and introduce DONT_RUN_GENERATED_CODE
Support DONT_RUN_GENERATED_CODE in JS Box tests. IGNORE_BACKEND_WITHOUT_CHECK is removed because of it's often wrongly used and in most cases can be replaced with IGNORE_BACKEND or DONT_RUN_GENERATED_CODE or with combination of them.
This commit is contained in:
@@ -233,12 +233,13 @@ public final class InTextDirectivesUtils {
|
|||||||
return ignoredBackends.contains(targetBackend.name());
|
return ignoredBackends.contains(targetBackend.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isIgnoredTargetWithoutCheck(TargetBackend targetBackend, File file) {
|
public static boolean dontRunGeneratedCode(TargetBackend targetBackend, File file) {
|
||||||
return isIgnoredTargetByPrefix(targetBackend, file, "// IGNORE_BACKEND_WITHOUT_CHECK: ");
|
List<String> backends = findListWithPrefixes(textWithDirectives(file), "// DONT_RUN_GENERATED_CODE: ");
|
||||||
|
return backends.contains(targetBackend.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Whether the target test is supposed to pass successfully on targetBackend
|
// Whether the target test is supposed to pass successfully on targetBackend
|
||||||
public static boolean isPassingTarget(TargetBackend targetBackend, File file) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -19,7 +19,6 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import static org.jetbrains.kotlin.test.InTextDirectivesUtils.isIgnoredTarget;
|
import static org.jetbrains.kotlin.test.InTextDirectivesUtils.isIgnoredTarget;
|
||||||
import static org.jetbrains.kotlin.test.InTextDirectivesUtils.isIgnoredTargetWithoutCheck;
|
|
||||||
|
|
||||||
public class SimpleTestMethodModel implements TestMethodModel {
|
public class SimpleTestMethodModel implements TestMethodModel {
|
||||||
|
|
||||||
@@ -96,8 +95,7 @@ public class SimpleTestMethodModel implements TestMethodModel {
|
|||||||
unescapedName = relativePath + "-" + StringsKt.capitalize(extractedName);
|
unescapedName = relativePath + "-" + StringsKt.capitalize(extractedName);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean ignored = isIgnoredTargetWithoutCheck(targetBackend, file) ||
|
boolean ignored = skipIgnored && isIgnoredTarget(targetBackend, file);
|
||||||
skipIgnored && isIgnoredTarget(targetBackend, file);
|
|
||||||
return (ignored ? "ignore" : "test") + StringsKt.capitalize(TestGeneratorUtil.escapeForJavaIdentifier(unescapedName));
|
return (ignored ? "ignore" : "test") + StringsKt.capitalize(TestGeneratorUtil.escapeForJavaIdentifier(unescapedName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,8 @@ abstract class BasicBoxTest(
|
|||||||
pathToRootOutputDir: String = BasicBoxTest.TEST_DATA_DIR_PATH,
|
pathToRootOutputDir: String = BasicBoxTest.TEST_DATA_DIR_PATH,
|
||||||
private val typedArraysEnabled: Boolean = true,
|
private val typedArraysEnabled: Boolean = true,
|
||||||
private val generateSourceMap: Boolean = false,
|
private val generateSourceMap: Boolean = false,
|
||||||
private val generateNodeJsRunner: Boolean = true
|
private val generateNodeJsRunner: Boolean = true,
|
||||||
|
private val targetBackend: TargetBackend = TargetBackend.JS
|
||||||
) : KotlinTestWithEnvironment() {
|
) : KotlinTestWithEnvironment() {
|
||||||
val additionalCommonFileDirectories = mutableListOf<String>()
|
val additionalCommonFileDirectories = mutableListOf<String>()
|
||||||
|
|
||||||
@@ -161,14 +162,18 @@ abstract class BasicBoxTest(
|
|||||||
val allJsFiles = additionalFiles + inputJsFiles + generatedJsFiles.map { it.first } + globalCommonFiles + localCommonFiles +
|
val allJsFiles = additionalFiles + inputJsFiles + generatedJsFiles.map { it.first } + globalCommonFiles + localCommonFiles +
|
||||||
additionalCommonFiles
|
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 nodeRunnerName = mainModule.outputFileName(outputDir) + ".node.js"
|
||||||
val ignored = InTextDirectivesUtils.isIgnoredTarget(TargetBackend.JS, file)
|
val ignored = InTextDirectivesUtils.isIgnoredTarget(TargetBackend.JS, file)
|
||||||
val nodeRunnerText = generateNodeRunner(allJsFiles, outputDir, mainModuleName, ignored, testPackage)
|
val nodeRunnerText = generateNodeRunner(allJsFiles, outputDir, mainModuleName, ignored, testPackage)
|
||||||
FileUtil.writeToFile(File(nodeRunnerName), nodeRunnerText)
|
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)
|
performAdditionalChecks(generatedJsFiles.map { it.first }, outputPrefixFile, outputPostfixFile)
|
||||||
|
|
||||||
@@ -202,16 +207,19 @@ abstract class BasicBoxTest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val outputDirForMinification = getOutputDir(file, testGroupOutputDirForMinification)
|
val outputDirForMinification = getOutputDir(file, testGroupOutputDirForMinification)
|
||||||
minifyAndRun(
|
|
||||||
workDir = File(outputDirForMinification, file.nameWithoutExtension),
|
if (!dontRunGeneratedCode) {
|
||||||
allJsFiles = allJsFiles,
|
minifyAndRun(
|
||||||
generatedJsFiles = generatedJsFiles,
|
workDir = File(outputDirForMinification, file.nameWithoutExtension),
|
||||||
expectedResult = expectedResult,
|
allJsFiles = allJsFiles,
|
||||||
testModuleName = mainModuleName,
|
generatedJsFiles = generatedJsFiles,
|
||||||
testPackage = testPackage,
|
expectedResult = expectedResult,
|
||||||
testFunction = testFunction,
|
testModuleName = mainModuleName,
|
||||||
withModuleSystem = withModuleSystem,
|
testPackage = testPackage,
|
||||||
minificationThresholdChecker = thresholdChecker)
|
testFunction = testFunction,
|
||||||
|
withModuleSystem = withModuleSystem,
|
||||||
|
minificationThresholdChecker = thresholdChecker)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.js.config.JsConfig
|
|||||||
import org.jetbrains.kotlin.js.facade.MainCallParameters
|
import org.jetbrains.kotlin.js.facade.MainCallParameters
|
||||||
import org.jetbrains.kotlin.js.facade.TranslationUnit
|
import org.jetbrains.kotlin.js.facade.TranslationUnit
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
import org.jetbrains.kotlin.test.TargetBackend
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
abstract class BasicIrBoxTest(
|
abstract class BasicIrBoxTest(
|
||||||
@@ -18,7 +19,15 @@ abstract class BasicIrBoxTest(
|
|||||||
pathToRootOutputDir: String = BasicBoxTest.TEST_DATA_DIR_PATH,
|
pathToRootOutputDir: String = BasicBoxTest.TEST_DATA_DIR_PATH,
|
||||||
generateSourceMap: Boolean = false,
|
generateSourceMap: Boolean = false,
|
||||||
generateNodeJsRunner: 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
|
override var skipMinification = true
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user