From 5bfda1d26c34e2021c70de2c23690265ca8c3e8a Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Sat, 7 May 2016 17:57:49 +0200 Subject: [PATCH] Add OS-specific staging for Env tests --- python/testSrc/com/jetbrains/TestEnv.java | 23 +++++++++++++ .../com/jetbrains/env/PyEnvTestCase.java | 18 +++++++++-- .../testSrc/com/jetbrains/env/PyToxTest.java | 5 +++ .../testSrc/com/jetbrains/env/StagingOn.java | 32 +++++++++++++++++++ .../env/python/PythonDebuggerTest.java | 6 ++++ 5 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 python/testSrc/com/jetbrains/TestEnv.java create mode 100644 python/testSrc/com/jetbrains/env/StagingOn.java diff --git a/python/testSrc/com/jetbrains/TestEnv.java b/python/testSrc/com/jetbrains/TestEnv.java new file mode 100644 index 000000000000..b78a9497dcbf --- /dev/null +++ b/python/testSrc/com/jetbrains/TestEnv.java @@ -0,0 +1,23 @@ +/* + * Copyright 2000-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. + */ +package com.jetbrains; + +/** + * @author traff + */ +public enum TestEnv { + WINDOWS, LINUX, MAC +} diff --git a/python/testSrc/com/jetbrains/env/PyEnvTestCase.java b/python/testSrc/com/jetbrains/env/PyEnvTestCase.java index 7288988735eb..f9017ae808e2 100644 --- a/python/testSrc/com/jetbrains/env/PyEnvTestCase.java +++ b/python/testSrc/com/jetbrains/env/PyEnvTestCase.java @@ -5,12 +5,14 @@ import com.intellij.execution.ExecutionException; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.testFramework.UsefulTestCase; import com.intellij.util.ArrayUtil; import com.intellij.util.SystemProperties; import com.intellij.util.ui.UIUtil; +import com.jetbrains.TestEnv; import com.jetbrains.python.packaging.PyPackage; import com.jetbrains.python.packaging.PyPackageManager; import org.hamcrest.Matchers; @@ -46,7 +48,7 @@ public abstract class PyEnvTestCase { public static final boolean RUN_REMOTE = SystemProperties.getBooleanProperty("pycharm.run_remote", false); public static final boolean RUN_LOCAL = SystemProperties.getBooleanProperty("pycharm.run_local", true); - + private static final boolean STAGING_ENV = SystemProperties.getBooleanProperty("pycharm.staging_env", false); /** @@ -73,7 +75,19 @@ public abstract class PyEnvTestCase { protected boolean isStaging(Description description) { try { - return description.getTestClass().getMethod(description.getMethodName()).isAnnotationPresent(Staging.class); + if (description.getTestClass().getMethod(description.getMethodName()).isAnnotationPresent(Staging.class)) { + return true; + } + else { + for (StagingOn so : description.getTestClass().getMethod(description.getMethodName()).getAnnotationsByType(StagingOn.class)) { + if (so.os() == TestEnv.WINDOWS && SystemInfo.isWindows || + so.os() == TestEnv.LINUX && SystemInfo.isLinux || + so.os() == TestEnv.MAC && SystemInfo.isMac) { + return true; + } + } + return false; + } } catch (NoSuchMethodException e) { return false; diff --git a/python/testSrc/com/jetbrains/env/PyToxTest.java b/python/testSrc/com/jetbrains/env/PyToxTest.java index 4cf96a2fe062..6faa1dba1ca8 100644 --- a/python/testSrc/com/jetbrains/env/PyToxTest.java +++ b/python/testSrc/com/jetbrains/env/PyToxTest.java @@ -20,6 +20,7 @@ import com.intellij.execution.testframework.sm.runner.SMTestProxy; import com.intellij.execution.testframework.sm.runner.ui.MockPrinter; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Pair; +import com.jetbrains.TestEnv; import com.jetbrains.python.PythonHelpersLocator; import com.jetbrains.python.sdkTools.SdkCreationType; import com.jetbrains.python.testing.tox.PyToxConfiguration; @@ -61,6 +62,7 @@ public final class PyToxTest extends PyEnvTestCase { * Check tox nose runner */ @Test + @StagingOn(os = TestEnv.WINDOWS) public void testToxNose() { runPythonTest(new MyPyProcessWithConsoleTestTask(1, new MyTestProcessRunner("/testData/toxtest/toxNose/"), @@ -79,6 +81,7 @@ public final class PyToxTest extends PyEnvTestCase { * Check tox pytest runner */ @Test + @StagingOn(os = TestEnv.WINDOWS) public void testToxPyTest() { runPythonTest(new MyPyProcessWithConsoleTestTask(1, new MyTestProcessRunner("/testData/toxtest/toxPyTest/"), @@ -97,6 +100,7 @@ public final class PyToxTest extends PyEnvTestCase { * Check tox unit runner */ @Test + @StagingOn(os = TestEnv.WINDOWS) public void testToxUnitTest() { runPythonTest(new MyPyProcessWithConsoleTestTask(1, new MyTestProcessRunner("/testData/toxtest/toxUnitTest/"), @@ -115,6 +119,7 @@ public final class PyToxTest extends PyEnvTestCase { * Big test which should run on any interpreter and check its output */ @Test + @StagingOn(os = TestEnv.WINDOWS) public void testToxSuccessTest() { runPythonTest(new MyPyProcessWithConsoleTestTask(1, new MyTestProcessRunner("/testData/toxtest/toxSuccess/"), diff --git a/python/testSrc/com/jetbrains/env/StagingOn.java b/python/testSrc/com/jetbrains/env/StagingOn.java new file mode 100644 index 000000000000..c6187278b8b1 --- /dev/null +++ b/python/testSrc/com/jetbrains/env/StagingOn.java @@ -0,0 +1,32 @@ +/* + * Copyright 2000-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. + */ +package com.jetbrains.env; + +import com.jetbrains.TestEnv; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author traff + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface StagingOn { + TestEnv os(); +} diff --git a/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java b/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java index 08b4bddcd606..e0d570cff412 100644 --- a/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java +++ b/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java @@ -9,9 +9,11 @@ import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.testFramework.UsefulTestCase; import com.intellij.testFramework.fixtures.IdeaProjectTestFixture; import com.intellij.xdebugger.XDebuggerTestUtil; +import com.jetbrains.TestEnv; import com.jetbrains.env.PyEnvTestCase; import com.jetbrains.env.PyProcessWithConsoleTestTask; import com.jetbrains.env.Staging; +import com.jetbrains.env.StagingOn; import com.jetbrains.env.python.debug.PyDebuggerTask; import com.jetbrains.env.ut.PyUnitTestProcessRunner; import com.jetbrains.python.PythonHelpersLocator; @@ -239,6 +241,7 @@ public class PythonDebuggerTest extends PyEnvTestCase { } @Test + @StagingOn(os = TestEnv.WINDOWS) public void testStepInto() throws Exception { runPythonTest(new PyDebuggerTask("/debug", "test2.py") { @Override @@ -350,6 +353,7 @@ public class PythonDebuggerTest extends PyEnvTestCase { } @Test + @StagingOn(os = TestEnv.WINDOWS) public void testRunToLine() throws Exception { runPythonTest(new PyDebuggerTask("/debug", "test_runtoline.py") { @Override @@ -535,6 +539,7 @@ public class PythonDebuggerTest extends PyEnvTestCase { } @Test + @StagingOn(os = TestEnv.WINDOWS) public void testEggDebug() throws Exception { runPythonTest(new PyDebuggerTask("/debug", "test_egg.py") { @Override @@ -607,6 +612,7 @@ public class PythonDebuggerTest extends PyEnvTestCase { } @Test + @StagingOn(os = TestEnv.WINDOWS) public void testWinLongName() throws Exception { if (UsefulTestCase.IS_UNDER_TEAMCITY && !SystemInfo.isWindows) { return; // Only needs to run on windows