diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/MethodChainsCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/MethodChainsCompletionTest.java index 74e46e08eea0..320c63cad8d5 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/MethodChainsCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/MethodChainsCompletionTest.java @@ -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"; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/HighlightStressTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/HighlightStressTest.java index 101fe0d2aa02..c593d04464f0 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/HighlightStressTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/HighlightStressTest.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 diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingPerformanceTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingPerformanceTest.java index a0d0ffc5c455..6b121b40de43 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingPerformanceTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingPerformanceTest.java @@ -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 diff --git a/java/java-tests/testSrc/com/intellij/index/IndexTest.java b/java/java-tests/testSrc/com/intellij/index/IndexTest.java index 7cbe2f678c98..fba5b6e5265d 100644 --- a/java/java-tests/testSrc/com/intellij/index/IndexTest.java +++ b/java/java-tests/testSrc/com/intellij/index/IndexTest.java @@ -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 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 void assertDataEquals(List actual, T... expected) { assertTrue(new HashSet(Arrays.asList(expected)).equals(new HashSet(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")); - + } }); } - + } diff --git a/java/java-tests/testSrc/com/intellij/psi/ClsDuplicatesTest.java b/java/java-tests/testSrc/com/intellij/psi/ClsDuplicatesTest.java index 81dcb5c3298a..dd32222cc7a8 100644 --- a/java/java-tests/testSrc/com/intellij/psi/ClsDuplicatesTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/ClsDuplicatesTest.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. @@ -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 myUnique = new THashSet(new TObjectHashingStrategy() { @Override diff --git a/java/java-tests/testSrc/com/intellij/psi/JavaSOEOnReparsePerformanceTest.java b/java/java-tests/testSrc/com/intellij/psi/JavaSOEOnReparsePerformanceTest.java index 4de8d98ae8fc..cf79fd890c69 100644 --- a/java/java-tests/testSrc/com/intellij/psi/JavaSOEOnReparsePerformanceTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/JavaSOEOnReparsePerformanceTest.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. @@ -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; diff --git a/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java b/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java index 95d54bb03a55..9250602002dd 100644 --- a/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.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. @@ -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); diff --git a/java/java-tests/testSrc/com/intellij/psi/PsiModificationTrackerTest.java b/java/java-tests/testSrc/com/intellij/psi/PsiModificationTrackerTest.java index bd9641f576b0..6dd124886989 100644 --- a/java/java-tests/testSrc/com/intellij/psi/PsiModificationTrackerTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/PsiModificationTrackerTest.java @@ -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 diff --git a/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java index 26c9c896512e..afecf29f1168 100644 --- a/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java +++ b/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.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. @@ -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 void registerExtension(final ExtensionPointName 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; } diff --git a/platform/testFramework/src/com/intellij/testFramework/SkipSlowTestLocally.java b/platform/testFramework/src/com/intellij/testFramework/SkipSlowTestLocally.java new file mode 100644 index 000000000000..80768b5fad93 --- /dev/null +++ b/platform/testFramework/src/com/intellij/testFramework/SkipSlowTestLocally.java @@ -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 { }