mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
test fix: skip ascii test on IronPython
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
package com.jetbrains.env;
|
||||
|
||||
import com.jetbrains.TestEnv;
|
||||
import com.jetbrains.python.sdk.flavors.PythonSdkFlavor;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -35,4 +36,5 @@ public @interface EnvTestTagsRequired {
|
||||
*/
|
||||
String[] tags();
|
||||
TestEnv[] skipOnOSes() default {};
|
||||
Class<? extends PythonSdkFlavor>[] skipOnFlavors() default {};
|
||||
}
|
||||
|
||||
+20
-2
@@ -15,12 +15,14 @@ import com.intellij.util.ObjectUtils;
|
||||
import com.jetbrains.LoggingRule;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import com.jetbrains.python.sdk.PythonSdkType;
|
||||
import com.jetbrains.python.sdk.flavors.PythonSdkFlavor;
|
||||
import com.jetbrains.python.tools.sdkTools.PySdkTools;
|
||||
import com.jetbrains.python.tools.sdkTools.SdkCreationType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -44,8 +46,17 @@ public class PyEnvTaskRunner {
|
||||
myLoggingRule = loggingRule;
|
||||
}
|
||||
|
||||
// todo: doc
|
||||
public void runTask(PyTestTask testTask, String testName, @NotNull final String... tagsRequiredByTest) {
|
||||
/**
|
||||
* Runs test on all interpreters.
|
||||
*
|
||||
* @param skipOnFlavors optional array of flavors of interpreters to skip
|
||||
*
|
||||
* @param tagsRequiredByTest optional array of tags to run tests on interpreters with these tags only
|
||||
*/
|
||||
public void runTask(@NotNull final PyTestTask testTask,
|
||||
@NotNull final String testName,
|
||||
@Nullable final Class<? extends PythonSdkFlavor>[] skipOnFlavors,
|
||||
@NotNull final String... tagsRequiredByTest) {
|
||||
boolean wasExecuted = false;
|
||||
|
||||
List<String> passedRoots = Lists.newArrayList();
|
||||
@@ -88,6 +99,13 @@ public class PyEnvTaskRunner {
|
||||
assert executable != null : "No executable in " + root;
|
||||
|
||||
final Sdk sdk = getSdk(executable, testTask);
|
||||
if (skipOnFlavors != null) {
|
||||
final PythonSdkFlavor flavor = PythonSdkFlavor.getFlavor(sdk);
|
||||
if (Arrays.stream(skipOnFlavors).anyMatch((o) -> o.isInstance(flavor))) {
|
||||
LOG.warn("Skipping flavor " + flavor.toString());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Skipping test if {@link PyTestTask} reports it does not support this language level
|
||||
|
||||
+14
-3
@@ -16,6 +16,7 @@ import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.jetbrains.LoggingRule;
|
||||
import com.jetbrains.TestEnv;
|
||||
import com.jetbrains.python.sdk.flavors.PythonSdkFlavor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.*;
|
||||
@@ -248,14 +249,24 @@ public abstract class PyEnvTestCase {
|
||||
catch (final NoSuchMethodException e) {
|
||||
throw new AssertionError("No such method", e);
|
||||
}
|
||||
if (classAnnotation != null) {
|
||||
Assume.assumeFalse("Test skipped on this os", Arrays.stream(classAnnotation.skipOnOSes()).anyMatch(TestEnv::isThisOs));
|
||||
final Class<? extends PythonSdkFlavor>[] skipOnFlavors;
|
||||
|
||||
|
||||
final EnvTestTagsRequired firstAnnotation = (methodAnnotation != null ? methodAnnotation : classAnnotation);
|
||||
|
||||
|
||||
if (firstAnnotation != null) {
|
||||
Assume.assumeFalse("Test skipped on this os", Arrays.stream(firstAnnotation.skipOnOSes()).anyMatch(TestEnv::isThisOs));
|
||||
skipOnFlavors = firstAnnotation.skipOnFlavors();
|
||||
}
|
||||
else {
|
||||
skipOnFlavors = null;
|
||||
}
|
||||
|
||||
final String[] classTags = getTags(classAnnotation);
|
||||
final String[] methodTags = getTags(methodAnnotation);
|
||||
|
||||
taskRunner.runTask(testTask, testName, ArrayUtil.mergeArrays(methodTags, classTags));
|
||||
taskRunner.runTask(testTask, testName, skipOnFlavors, ArrayUtil.mergeArrays(methodTags, classTags));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+3
-6
@@ -15,24 +15,20 @@
|
||||
*/
|
||||
package com.jetbrains.env.python.testing;
|
||||
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.EdtTestUtil;
|
||||
import com.intellij.testFramework.fixtures.CodeInsightTestFixture;
|
||||
import com.jetbrains.env.EnvTestTagsRequired;
|
||||
import com.jetbrains.env.PyEnvTestCase;
|
||||
import com.jetbrains.env.ut.PyScriptTestProcessRunner;
|
||||
import com.jetbrains.env.ut.PyUnitTestProcessRunner;
|
||||
import com.jetbrains.python.PyBundle;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import com.jetbrains.python.sdk.flavors.IronPythonSdkFlavor;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.jetbrains.env.ut.PyScriptTestProcessRunner.TEST_TARGET_PREFIX;
|
||||
@@ -70,6 +66,7 @@ public abstract class PythonUnitTestingLikeTest<T extends PyScriptTestProcessRun
|
||||
* Ensure that sys.path[0] is script folder, not helpers folder
|
||||
*/
|
||||
@Test
|
||||
@EnvTestTagsRequired(tags = {}, skipOnFlavors = {IronPythonSdkFlavor.class})
|
||||
public void testSysPath() throws Exception {
|
||||
runPythonTest(new PyUnitTestLikeProcessWithConsoleTestTask<T>("testRunner/env/unit/sysPath", "test_sample.py", this::createTestRunner) {
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.jetbrains.python.psi.LanguageLevel;
|
||||
import com.jetbrains.python.psi.PyFunction;
|
||||
import com.jetbrains.python.run.targetBasedConfiguration.PyRunTargetVariant;
|
||||
import com.jetbrains.python.sdk.InvalidSdkException;
|
||||
import com.jetbrains.python.sdk.flavors.IronPythonSdkFlavor;
|
||||
import com.jetbrains.python.testing.ConfigurationTarget;
|
||||
import com.jetbrains.python.testing.PyUnitTestConfiguration;
|
||||
import com.jetbrains.python.testing.PyUnitTestFactory;
|
||||
@@ -229,6 +230,7 @@ public final class PythonUnitTestingTest extends PythonUnitTestingLikeTest<PyUni
|
||||
* check non-ascii (127+) chars are supported in skip messaged
|
||||
*/
|
||||
@Test
|
||||
@EnvTestTagsRequired(tags = {}, skipOnFlavors = {IronPythonSdkFlavor.class})
|
||||
public void testNonAsciiMessage() {
|
||||
|
||||
runPythonTest(new PyUnitTestProcessWithConsoleTestTask("testRunner/env/unit/nonAscii", "test_test.py") {
|
||||
|
||||
Reference in New Issue
Block a user