mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
java: ability to skip slow tests
This commit is contained in:
+17
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
@@ -9,6 +24,7 @@ import com.intellij.compiler.classFilesIndex.chainsSearch.completion.MethodsChai
|
||||
import com.intellij.compiler.classFilesIndex.chainsSearch.completion.lookup.ChainCompletionMethodCallLookupElement;
|
||||
import com.intellij.compiler.classFilesIndex.chainsSearch.completion.lookup.WeightableChainLookupElement;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.testFramework.SkipSlowTestLocally;
|
||||
import com.intellij.util.SmartList;
|
||||
|
||||
import java.util.List;
|
||||
@@ -16,6 +32,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author Dmitry Batkovich
|
||||
*/
|
||||
@SkipSlowTestLocally
|
||||
public class MethodChainsCompletionTest extends AbstractCompilerAwareTest {
|
||||
private final static String TEST_INDEX_FILE_NAME = "TestIndex.java";
|
||||
private final static String TEST_COMPLETION_FILE_NAME = "TestCompletion.java";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -37,6 +37,7 @@ import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.PsiShortNamesCache;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.testFramework.SkipSlowTestLocally;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -44,6 +45,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@SkipSlowTestLocally
|
||||
public class HighlightStressTest extends LightDaemonAnalyzerTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -28,12 +28,14 @@ import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.impl.source.tree.injected.JavaConcatenationInjectorManager;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.testFramework.SkipSlowTestLocally;
|
||||
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl;
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SkipSlowTestLocally
|
||||
public class LightAdvHighlightingPerformanceTest extends LightDaemonAnalyzerTestCase {
|
||||
private final Disposable my = Disposer.newDisposable();
|
||||
@Override
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.intellij.psi.search.PsiSearchHelper;
|
||||
import com.intellij.testFramework.IdeaTestCase;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.testFramework.SkipSlowTestLocally;
|
||||
import com.intellij.util.indexing.MapIndexStorage;
|
||||
import com.intellij.util.indexing.StorageException;
|
||||
import com.intellij.util.io.*;
|
||||
@@ -44,8 +45,9 @@ import java.util.*;
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Dec 12, 2007
|
||||
*/
|
||||
@SkipSlowTestLocally
|
||||
public class IndexTest extends IdeaTestCase {
|
||||
|
||||
|
||||
public void testUpdate() throws StorageException, IOException {
|
||||
final File storageFile = FileUtil.createTempFile("indextest", "storage");
|
||||
final File metaIndexFile = FileUtil.createTempFile("indextest_inputs", "storage");
|
||||
@@ -137,7 +139,7 @@ public class IndexTest extends IdeaTestCase {
|
||||
FileTypeManager.getInstance().registerFileType(TestFileType.INSTANCE, "fff");
|
||||
final FFFLangParserDefinition parserDefinition = new FFFLangParserDefinition();
|
||||
LanguageParserDefinitions.INSTANCE.addExplicitExtension(FFFLanguage.INSTANCE, parserDefinition);
|
||||
|
||||
|
||||
final TestStubElementType stubType = new TestStubElementType();
|
||||
SerializationManager.getInstance().registerSerializer(TestStubElement.class, stubType);
|
||||
|
||||
@@ -145,7 +147,7 @@ public class IndexTest extends IdeaTestCase {
|
||||
fffFile.createNewFile();
|
||||
|
||||
final VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(fffFile);
|
||||
|
||||
|
||||
assertNotNull(vFile);
|
||||
assertEquals(TestFileType.INSTANCE, vFile.getFileType());
|
||||
|
||||
@@ -181,9 +183,9 @@ public class IndexTest extends IdeaTestCase {
|
||||
final List<SerializedStubTree> trees = data.toValueList();
|
||||
|
||||
final SerializedStubTree tree = assertOneElement(trees);
|
||||
|
||||
|
||||
assertTrue(Comparing.equal(bytes, tree.getBytes()));
|
||||
|
||||
|
||||
final StubElement deserialized = tree.getStub();
|
||||
}
|
||||
finally {
|
||||
@@ -192,7 +194,7 @@ public class IndexTest extends IdeaTestCase {
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
private static <T> void assertDataEquals(List<T> actual, T... expected) {
|
||||
assertTrue(new HashSet<T>(Arrays.asList(expected)).equals(new HashSet<T>(actual)));
|
||||
}
|
||||
@@ -200,7 +202,7 @@ public class IndexTest extends IdeaTestCase {
|
||||
public void testCollectedPsiWithChangedDocument() throws IOException {
|
||||
VirtualFile dir = getVirtualFile(createTempDirectory());
|
||||
PsiTestUtil.addSourceContentToRoots(myModule, dir);
|
||||
|
||||
|
||||
final VirtualFile vFile = createChildData(dir, "Foo.java");
|
||||
VfsUtil.saveText(vFile, "class Foo {}");
|
||||
|
||||
@@ -232,11 +234,11 @@ public class IndexTest extends IdeaTestCase {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void testSavedUncommittedDocument() throws IOException {
|
||||
VirtualFile dir = getVirtualFile(createTempDirectory());
|
||||
PsiTestUtil.addSourceContentToRoots(myModule, dir);
|
||||
|
||||
|
||||
final VirtualFile vFile = createChildData(dir, "Foo.java");
|
||||
VfsUtil.saveText(vFile, "");
|
||||
|
||||
@@ -254,10 +256,10 @@ public class IndexTest extends IdeaTestCase {
|
||||
Document document = FileDocumentManager.getInstance().getDocument(vFile);
|
||||
document.insertString(0, "class Foo {}");
|
||||
FileDocumentManager.getInstance().saveDocument(document);
|
||||
|
||||
|
||||
assertTrue(count == PsiManager.getInstance(myProject).getModificationTracker().getModificationCount());
|
||||
assertNull(facade.findClass("Foo", scope));
|
||||
|
||||
|
||||
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
|
||||
assertNotNull(facade.findClass("Foo", scope));
|
||||
assertNotNull(facade.findClass("Foo", scope).getText());
|
||||
@@ -279,11 +281,11 @@ public class IndexTest extends IdeaTestCase {
|
||||
final Document document = FileDocumentManager.getInstance().getDocument(vFile);
|
||||
//todo should file type be changed silently without events?
|
||||
//assertEquals(UnknownFileType.INSTANCE, vFile.getFileType());
|
||||
|
||||
|
||||
final PsiFile file = getPsiFile(document);
|
||||
assertInstanceOf(file, PsiPlainTextFile.class);
|
||||
assertEquals("Foo", file.getText());
|
||||
|
||||
|
||||
assertEmpty(PsiSearchHelper.SERVICE.getInstance(myProject).findFilesWithPlainTextWords("Foo"));
|
||||
|
||||
WriteCommandAction.runWriteCommandAction(myProject, new Runnable() {
|
||||
@@ -296,13 +298,13 @@ public class IndexTest extends IdeaTestCase {
|
||||
FileDocumentManager.getInstance().saveDocument(document);
|
||||
assertEquals("Foo", file.getText());
|
||||
assertEmpty(PsiSearchHelper.SERVICE.getInstance(myProject).findFilesWithPlainTextWords("Foo"));
|
||||
|
||||
|
||||
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
|
||||
assertEquals(" Foo", file.getText());
|
||||
assertEmpty(PsiSearchHelper.SERVICE.getInstance(myProject).findFilesWithPlainTextWords("Foo"));
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -20,12 +20,14 @@ import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.testFramework.PsiTestCase;
|
||||
import com.intellij.testFramework.SkipSlowTestLocally;
|
||||
import com.intellij.usageView.UsageViewLongNameLocation;
|
||||
import gnu.trove.THashSet;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@SkipSlowTestLocally
|
||||
public class ClsDuplicatesTest extends PsiTestCase {
|
||||
private Set<PsiNamedElement> myUnique = new THashSet<PsiNamedElement>(new TObjectHashingStrategy<PsiNamedElement>() {
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -18,7 +18,9 @@ package com.intellij.psi;
|
||||
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.testFramework.SkipSlowTestLocally;
|
||||
|
||||
@SkipSlowTestLocally
|
||||
public class JavaSOEOnReparsePerformanceTest extends LightDaemonAnalyzerTestCase {
|
||||
private StringBuilder myHugeExpr;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -31,25 +31,17 @@ import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.testFramework.PsiTestCase;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.testFramework.Timings;
|
||||
import com.intellij.testFramework.*;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@SkipSlowTestLocally
|
||||
public class PsiConcurrencyStressTest extends PsiTestCase {
|
||||
private static final boolean SKIP = "true".equalsIgnoreCase(System.getProperty("skip.psi.concurrency.test"));
|
||||
|
||||
@Override
|
||||
public void runBare() throws Throwable {
|
||||
if (!SKIP) {
|
||||
super.runBare();
|
||||
}
|
||||
}
|
||||
private volatile PsiJavaFile myFile;
|
||||
private volatile boolean writeActionInProgress;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
@@ -61,8 +53,6 @@ public class PsiConcurrencyStressTest extends PsiTestCase {
|
||||
PsiTestUtil.createTestProjectStructure(myProject, myModule, root, myFilesToDelete);
|
||||
}
|
||||
|
||||
private volatile PsiJavaFile myFile;
|
||||
private volatile boolean writeActionInProgress;
|
||||
public void testStress() throws Exception {
|
||||
int numOfThreads = 10;
|
||||
int iterations = Timings.adjustAccordingToMySpeed(20, true);
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
@@ -12,6 +27,7 @@ import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiModificationTracker;
|
||||
import com.intellij.testFramework.IdeaTestCase;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.testFramework.SkipSlowTestLocally;
|
||||
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -22,6 +38,7 @@ import java.io.IOException;
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
@SkipSlowTestLocally
|
||||
public class PsiModificationTrackerTest extends LightPlatformCodeInsightFixtureTestCase {
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
@@ -171,7 +188,7 @@ public class PsiModificationTrackerTest extends LightPlatformCodeInsightFixtureT
|
||||
assertSize(0, psiFile.getClasses());
|
||||
assertEquals("", psiManager.findFile(file).getText());
|
||||
PlatformTestUtil.tryGcSoftlyReachableObjects();
|
||||
|
||||
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
|
||||
assertFalse(count1 == tracker.getJavaStructureModificationCount());
|
||||
@@ -182,7 +199,7 @@ public class PsiModificationTrackerTest extends LightPlatformCodeInsightFixtureT
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
|
||||
public void testClassShouldNotAppearWithoutEvents_WithoutPsi() throws IOException {
|
||||
final GlobalSearchScope allScope = GlobalSearchScope.allScope(getProject());
|
||||
final JavaPsiFacade facade = JavaPsiFacade.getInstance(getProject());
|
||||
@@ -197,7 +214,7 @@ public class PsiModificationTrackerTest extends LightPlatformCodeInsightFixtureT
|
||||
protected void run() throws Throwable {
|
||||
assertNull(facade.findClass("Foo", allScope));
|
||||
long count1 = tracker.getJavaStructureModificationCount();
|
||||
|
||||
|
||||
PlatformTestUtil.tryGcSoftlyReachableObjects();
|
||||
assertNull(PsiDocumentManager.getInstance(getProject()).getCachedPsiFile(document));
|
||||
|
||||
@@ -232,7 +249,7 @@ public class PsiModificationTrackerTest extends LightPlatformCodeInsightFixtureT
|
||||
|
||||
document.deleteString(0, document.getTextLength());
|
||||
|
||||
// some plugins (e.g. Copyright) hold file reference in an invokeLater runnable, let them pass
|
||||
// some plugins (e.g. Copyright) hold file reference in an invokeLater runnable, let them pass
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
|
||||
// gc softly-referenced file and AST
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -89,6 +89,9 @@ public class PlatformTestUtil {
|
||||
public static final boolean COVERAGE_ENABLED_BUILD = "true".equals(System.getProperty("idea.coverage.enabled.build"));
|
||||
public static final byte[] EMPTY_JAR_BYTES = {0x50, 0x4b, 0x05, 0x06, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,};
|
||||
|
||||
private static final boolean SKIP_HEADLESS = GraphicsEnvironment.isHeadless();
|
||||
private static final boolean SKIP_SLOW = Boolean.getBoolean("skip.slow.tests.locally");
|
||||
|
||||
public static <T> void registerExtension(final ExtensionPointName<T> name, final T t, final Disposable parentDisposable) {
|
||||
registerExtension(Extensions.getRootArea(), name, t, parentDisposable);
|
||||
}
|
||||
@@ -419,14 +422,21 @@ public class PlatformTestUtil {
|
||||
}
|
||||
|
||||
public static boolean canRunTest(@NotNull Class testCaseClass) {
|
||||
if (GraphicsEnvironment.isHeadless()) {
|
||||
for (Class<?> clazz = testCaseClass; clazz != null; clazz = clazz.getSuperclass()) {
|
||||
if (clazz.getAnnotation(SkipInHeadlessEnvironment.class) != null) {
|
||||
System.out.println("Class '" + testCaseClass.getName() + "' is skipped because it requires working UI environment");
|
||||
return false;
|
||||
}
|
||||
if (!SKIP_SLOW && !SKIP_HEADLESS) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (Class<?> clazz = testCaseClass; clazz != null; clazz = clazz.getSuperclass()) {
|
||||
if (SKIP_HEADLESS && clazz.getAnnotation(SkipInHeadlessEnvironment.class) != null) {
|
||||
System.out.println("Class '" + testCaseClass.getName() + "' is skipped because it requires working UI environment");
|
||||
return false;
|
||||
}
|
||||
if (SKIP_SLOW && clazz.getAnnotation(SkipSlowTestLocally.class) != null) {
|
||||
System.out.println("Class '" + testCaseClass.getName() + "' is skipped because it is dog slow");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package com.intellij.testFramework;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Mark dog slow {@link com.intellij.testFramework.UsefulTestCase} implementations for skip in local test pass
|
||||
* if "skip.slow.tests.locally" property is defined.
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface SkipSlowTestLocally { }
|
||||
Reference in New Issue
Block a user