diff --git a/platform/testFramework/core/src/com/intellij/idea/extensions/SkipSlowExecutionCondition.java b/platform/testFramework/core/src/com/intellij/idea/extensions/SkipSlowExecutionCondition.java new file mode 100644 index 000000000000..8d0e8a64fd45 --- /dev/null +++ b/platform/testFramework/core/src/com/intellij/idea/extensions/SkipSlowExecutionCondition.java @@ -0,0 +1,20 @@ +// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.idea.extensions; + +import com.intellij.testFramework.SkipSlowTestLocally; +import org.junit.jupiter.api.extension.ConditionEvaluationResult; +import org.junit.jupiter.api.extension.ExecutionCondition; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.platform.commons.support.AnnotationSupport; + +public class SkipSlowExecutionCondition implements ExecutionCondition { + private static final ConditionEvaluationResult ENABLED = ConditionEvaluationResult.enabled("Enabled locally"); + private static final ConditionEvaluationResult DISABLED = ConditionEvaluationResult.disabled("Slow tests are disabled locally"); + private static final boolean SKIP_SLOW_TESTS = System.getProperty("skip.slow.tests.locally") != null; + + @Override + public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { + if (!SKIP_SLOW_TESTS) return ENABLED; + return AnnotationSupport.findAnnotation(context.getTestClass(), SkipSlowTestLocally.class).isPresent() ? DISABLED : ENABLED; + } +} diff --git a/platform/testFramework/core/src/com/intellij/testFramework/SkipSlowTestLocally.java b/platform/testFramework/core/src/com/intellij/testFramework/SkipSlowTestLocally.java index 80768b5fad93..f5e057243fec 100644 --- a/platform/testFramework/core/src/com/intellij/testFramework/SkipSlowTestLocally.java +++ b/platform/testFramework/core/src/com/intellij/testFramework/SkipSlowTestLocally.java @@ -1,20 +1,9 @@ -/* - * Copyright 2000-2014 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 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.testFramework; +import com.intellij.idea.extensions.SkipSlowExecutionCondition; +import org.junit.jupiter.api.extension.ExtendWith; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -26,4 +15,5 @@ import java.lang.annotation.Target; */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) +@ExtendWith(SkipSlowExecutionCondition.class) public @interface SkipSlowTestLocally { }