[Test infra] Take into account transitive compatible targets while checking compatibility.

This commit is contained in:
Zalim Bashorov
2020-07-10 02:29:24 +03:00
parent ca37c6bfe6
commit c552933459
2 changed files with 62 additions and 2 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -231,7 +231,12 @@ public final class InTextDirectivesUtils {
return false;
List<String> backends = findLinesWithPrefixesRemoved(textWithDirectives(file), "// TARGET_BACKEND: ");
return backends.isEmpty() || backends.contains(targetBackend.name()) || backends.contains(targetBackend.getCompatibleWith().name());
return isCompatibleTargetExceptAny(targetBackend, backends);
}
private static boolean isCompatibleTargetExceptAny(TargetBackend targetBackend, List<String> backends) {
if (targetBackend == TargetBackend.ANY) return false;
return backends.isEmpty() || backends.contains(targetBackend.name()) || isCompatibleTargetExceptAny(targetBackend.getCompatibleWith(), backends);
}
public static boolean isIgnoredTarget(TargetBackend targetBackend, File file, String ignoreBackendDirectivePrefix) {