From 9387a6c26491c09147447accd1b2b6b689dde88c Mon Sep 17 00:00:00 2001 From: Vladislav Shishov Date: Mon, 4 Mar 2019 15:47:47 +0300 Subject: [PATCH] [gui-test] add DisabledOnOs annotation --- .../framework/GuiTestRunner.kt | 19 +++++++++++++++++-- .../testGuiFramework/util/DisabledOnOs.kt | 8 ++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 platform/testGuiFramework/src/com/intellij/testGuiFramework/util/DisabledOnOs.kt diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/GuiTestRunner.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/GuiTestRunner.kt index 2da3418d63b7..c6a51d22f0a3 100755 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/GuiTestRunner.kt +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/GuiTestRunner.kt @@ -27,6 +27,7 @@ import com.intellij.testGuiFramework.launcher.GradleLauncher import com.intellij.testGuiFramework.launcher.GuiTestLocalLauncher import com.intellij.testGuiFramework.launcher.GuiTestOptions import com.intellij.testGuiFramework.launcher.ide.Ide +import com.intellij.testGuiFramework.launcher.system.SystemInfo import com.intellij.testGuiFramework.remote.IdeControl.closeIde import com.intellij.testGuiFramework.remote.IdeControl.ensureIdeIsRunning import com.intellij.testGuiFramework.remote.IdeControl.restartIde @@ -37,6 +38,7 @@ import com.intellij.testGuiFramework.remote.server.JUnitServerHolder import com.intellij.testGuiFramework.remote.transport.* import com.intellij.testGuiFramework.testCases.PluginTestCase.Companion.PLUGINS_INSTALLED import com.intellij.testGuiFramework.testCases.SystemPropertiesTestCase.Companion.SYSTEM_PROPERTIES +import com.intellij.testGuiFramework.util.DisabledOnOs import com.intellij.util.io.exists import org.junit.Assert import org.junit.AssumptionViolatedException @@ -81,11 +83,20 @@ open class GuiTestRunner internal constructor(open val runner: GuiTestRunnerInte val systemProperties = getSystemPropertiesFromAnnotation(method.declaringClass) val eachNotifier = EachTestNotifier(notifier, description) - if (criticalError.get()) { - eachNotifier.fireTestIgnored(); return + + if (testShouldBeIgnored(method)) { + eachNotifier.fireTestIgnored() + return } val testName = runner.getTestName(method.name) + + if (criticalError.get()) { + SERVER_LOG.info("Test $testName ignored by @DisabledOnOs annotation") + eachNotifier.fireTestIgnored() + return + } + SERVER_LOG.info("Starting test on server side: $testName") try { @@ -270,6 +281,10 @@ open class GuiTestRunner internal constructor(open val runner: GuiTestRunnerInte companion object { private val LOG = Logger.getInstance("#com.intellij.testGuiFramework.framework.GuiTestRunner") + + private fun testShouldBeIgnored(test: FrameworkMethod): Boolean = + test.getAnnotation(DisabledOnOs::class.java)?.os?.contains(SystemInfo.getSystemType()) ?: false || + test.declaringClass.getAnnotation(DisabledOnOs::class.java)?.os?.contains(SystemInfo.getSystemType()) ?: false } } diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/util/DisabledOnOs.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/util/DisabledOnOs.kt new file mode 100644 index 000000000000..6910933fd07c --- /dev/null +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/util/DisabledOnOs.kt @@ -0,0 +1,8 @@ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package com.intellij.testGuiFramework.util + +import com.intellij.testGuiFramework.launcher.system.SystemInfo + +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +@Retention(AnnotationRetention.RUNTIME) +annotation class DisabledOnOs(vararg val os: SystemInfo.SystemType)