Add generating tests using "whitelist" of target backend; add new target backends: JS_IR and JVM_IR
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 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.
|
||||
*/
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.google.common.collect.Sets;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import kotlin.io.FilesKt;
|
||||
import kotlin.text.StringsKt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -232,6 +233,8 @@ public final class InTextDirectivesUtils {
|
||||
}
|
||||
|
||||
public static boolean isIgnoredTarget(TargetBackend targetBackend, File file) {
|
||||
if (!isAllowedByWhitelist(targetBackend, file)) return true;
|
||||
|
||||
return isIgnoredTargetByPrefix(targetBackend, file, "// IGNORE_BACKEND: ");
|
||||
}
|
||||
|
||||
@@ -243,4 +246,17 @@ public final class InTextDirectivesUtils {
|
||||
public static boolean isPassingTarget(TargetBackend targetBackend, File file) {
|
||||
return isCompatibleTarget(targetBackend, file) && !isIgnoredTarget(targetBackend, file) && !isIgnoredTargetWithoutCheck(targetBackend, file);
|
||||
}
|
||||
|
||||
private static boolean isAllowedByWhitelist(@NotNull TargetBackend targetBackend, @NotNull File file) {
|
||||
List<File> whitelist = targetBackend.getWhitelist();
|
||||
if (whitelist == null) return true;
|
||||
|
||||
for (File entry : whitelist) {
|
||||
if (FilesKt.startsWith(file, entry)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
/*
|
||||
* Copyright 2010-2016 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;
|
||||
package org.jetbrains.kotlin.test
|
||||
|
||||
enum class TargetBackend {
|
||||
import java.io.File
|
||||
|
||||
enum class TargetBackend(
|
||||
// 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
|
||||
val whitelist: List<File>? = null
|
||||
) {
|
||||
ANY,
|
||||
JVM,
|
||||
JS
|
||||
JVM_IR,
|
||||
JS,
|
||||
JS_IR(JS_IR_BACKEND_TEST_WHITELIST);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
import java.io.File
|
||||
|
||||
val JS_IR_BACKEND_TEST_WHITELIST = listOf(
|
||||
"js/js.translator/testData/box/annotation"
|
||||
).map { File(it) }
|
||||
+1
-1
@@ -94,7 +94,7 @@ public class SimpleTestMethodModel implements TestMethodModel {
|
||||
p.println("return;");
|
||||
p.popIndent();
|
||||
p.println("}");
|
||||
p.println("throw new AssertionError(\"Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.\");");
|
||||
p.println("throw new AssertionError(\"Looks like this test can be unmuted. Remove IGNORE_BACKEND directive or add it to whitelist for that.\");");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user