Few improvements in test infrastructure:
* add the way to specify another compatible target for target backend. It's used to generate a test for X_IR backend even when in a test data is explicitly written a target: "// TARGET_BACKEND: X". * Add the ability to run tests "ignored" with the "IGNORE_BACKEND" directive as regular tests, i.e. w/o catching exceptions. * Print stack trace of caught exception inside tests "ignored" with the "IGNORE_BACKEND" directive.
This commit is contained in:
@@ -222,7 +222,7 @@ public final class InTextDirectivesUtils {
|
||||
if (targetBackend == TargetBackend.ANY) return true;
|
||||
|
||||
List<String> backends = findLinesWithPrefixesRemoved(textWithDirectives(file), "// TARGET_BACKEND: ");
|
||||
return backends.isEmpty() || backends.contains(targetBackend.name());
|
||||
return backends.isEmpty() || backends.contains(targetBackend.name()) || backends.contains(targetBackend.getCompatibleWith().name());
|
||||
}
|
||||
|
||||
private static boolean isIgnoredTargetByPrefix(TargetBackend targetBackend, File file, String prefix) {
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.test;
|
||||
@@ -107,6 +96,9 @@ public class KotlinTestUtils {
|
||||
public static final String TEST_GENERATOR_NAME = "org.jetbrains.kotlin.generators.tests.TestsPackage";
|
||||
public static final String PLEASE_REGENERATE_TESTS = "Please regenerate tests (GenerateTests.kt)";
|
||||
|
||||
public static final boolean RUN_IGNORED_TESTS_AS_REGULAR =
|
||||
Boolean.getBoolean("org.jetbrains.kotlin.run.ignored.tests.as.regular");
|
||||
|
||||
private static final List<File> filesToDelete = new ArrayList<>();
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.test
|
||||
import java.io.File
|
||||
|
||||
enum class TargetBackend(
|
||||
private val compatibleWithTargetBackend: TargetBackend? = null,
|
||||
// if whitelist === null it will not be used in test generator (will work as usual)
|
||||
// if path to testData file starts with or equals to any entry from whitelist it will be processed as usual
|
||||
// otherwise a testData file will be treated as ignored
|
||||
@@ -15,7 +16,9 @@ enum class TargetBackend(
|
||||
) {
|
||||
ANY,
|
||||
JVM,
|
||||
JVM_IR,
|
||||
JVM_IR(JVM),
|
||||
JS,
|
||||
JS_IR(JS_IR_BACKEND_TEST_WHITELIST);
|
||||
JS_IR(JS, JS_IR_BACKEND_TEST_WHITELIST);
|
||||
|
||||
val compatibleWith get() = compatibleWithTargetBackend ?: ANY
|
||||
}
|
||||
|
||||
+14
-15
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.generators.tests.generator;
|
||||
@@ -79,18 +68,28 @@ public class SimpleTestMethodModel implements TestMethodModel {
|
||||
String filePath = KotlinTestUtils.getFilePath(file) + (file.isDirectory() ? "/" : "");
|
||||
p.println("String fileName = KotlinTestUtils.navigationMetadata(\"", filePath, "\");");
|
||||
|
||||
if (isIgnoredTarget(targetBackend, file)) {
|
||||
boolean ignoredTarget = isIgnoredTarget(targetBackend, file);
|
||||
|
||||
if (ignoredTarget) {
|
||||
p.println("if (KotlinTestUtils.RUN_IGNORED_TESTS_AS_REGULAR) {");
|
||||
p.pushIndent();
|
||||
p.println(doTestMethodName, "(fileName);");
|
||||
p.println("return;");
|
||||
p.popIndent();
|
||||
p.println("}");
|
||||
|
||||
p.println("try {");
|
||||
p.pushIndent();
|
||||
}
|
||||
|
||||
p.println(doTestMethodName, "(fileName);");
|
||||
|
||||
if (isIgnoredTarget(targetBackend, file)) {
|
||||
if (ignoredTarget) {
|
||||
p.popIndent();
|
||||
p.println("}");
|
||||
p.println("catch (Throwable ignore) {");
|
||||
p.pushIndent();
|
||||
p.println("ignore.printStackTrace();");
|
||||
p.println("return;");
|
||||
p.popIndent();
|
||||
p.println("}");
|
||||
|
||||
Reference in New Issue
Block a user