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 c99ca3c8f74..36b373b2fb2 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/InTextDirectivesUtils.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/InTextDirectivesUtils.java @@ -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 whitelist = targetBackend.getWhitelist(); + if (whitelist == null) return true; + + for (File entry : whitelist) { + if (FilesKt.startsWith(file, entry)) { + return true; + } + } + + return false; + } } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/TargetBackend.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/test/TargetBackend.kt index baeeea72a88..b47bbf4134b 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/TargetBackend.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/TargetBackend.kt @@ -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? = null +) { ANY, JVM, - JS + JVM_IR, + JS, + JS_IR(JS_IR_BACKEND_TEST_WHITELIST); } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/jsIrBackendTestWhitelist.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/test/jsIrBackendTestWhitelist.kt new file mode 100644 index 00000000000..68b8401ea7b --- /dev/null +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/jsIrBackendTestWhitelist.kt @@ -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) } 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 93a5fd624c7..e859409e01e 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 @@ -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.\");"); } }