[gui-test] add DisabledOnOs annotation

This commit is contained in:
Vladislav Shishov
2019-03-04 15:53:09 +03:00
parent 048fa3441b
commit 9387a6c264
2 changed files with 25 additions and 2 deletions
@@ -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
}
}
@@ -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)