From 43dfc060abaeddcfdc42809eeaee0b88ae0a1848 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 18 Nov 2014 11:47:49 +0100 Subject: [PATCH] merge IndexGeneratedTest into IndexTest --- .../intellij/index/IndexGeneratedTest.groovy | 57 ------------------- .../com/intellij/index/IndexTest.groovy | 25 ++++++++ .../intellij/index/IndexTestGenerator.scala | 7 ++- 3 files changed, 30 insertions(+), 59 deletions(-) delete mode 100644 java/java-tests/testSrc/com/intellij/index/IndexGeneratedTest.groovy diff --git a/java/java-tests/testSrc/com/intellij/index/IndexGeneratedTest.groovy b/java/java-tests/testSrc/com/intellij/index/IndexGeneratedTest.groovy deleted file mode 100644 index 8e06c9bdf5a4..000000000000 --- a/java/java-tests/testSrc/com/intellij/index/IndexGeneratedTest.groovy +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.index -import com.intellij.openapi.command.WriteCommandAction -import com.intellij.openapi.fileEditor.FileDocumentManager -import com.intellij.openapi.vfs.VfsUtil -import com.intellij.psi.JavaPsiFacade -import com.intellij.psi.PsiDocumentManager -import com.intellij.psi.PsiFile -import com.intellij.psi.impl.PsiManagerEx -import com.intellij.psi.search.GlobalSearchScope -import com.intellij.testFramework.PlatformTestUtil -import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase -import com.intellij.util.TimeoutUtil - -class IndexGeneratedTest extends JavaCodeInsightFixtureTestCase { - protected void invokeTestRunnable(Runnable runnable) { - WriteCommandAction.runWriteCommandAction(project, runnable) - } - - public void "test changing a file without psi makes the document committed and updates index"() { - def psiFile = myFixture.addFileToProject("Foo.java", "class Foo {}") - def vFile = psiFile.virtualFile - def scope = GlobalSearchScope.allScope(project) - - FileDocumentManager.instance.getDocument(vFile).text = "import zoo.Zoo; class Foo1 {}" - assert PsiDocumentManager.getInstance(project).uncommittedDocuments - psiFile = null - - PlatformTestUtil.tryGcSoftlyReachableObjects() - - assert !((PsiManagerEx) psiManager).fileManager.getCachedPsiFile(vFile) - - FileDocumentManager.instance.saveAllDocuments() - - VfsUtil.saveText(vFile, "class Foo3 {}") - - assert !PsiDocumentManager.getInstance(project).uncommittedDocuments - - assert JavaPsiFacade.getInstance(project).findClass("Foo3", scope) - } - - -} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/index/IndexTest.groovy b/java/java-tests/testSrc/com/intellij/index/IndexTest.groovy index ed1efa093b33..64492f94d62a 100644 --- a/java/java-tests/testSrc/com/intellij/index/IndexTest.groovy +++ b/java/java-tests/testSrc/com/intellij/index/IndexTest.groovy @@ -25,9 +25,11 @@ import com.intellij.openapi.fileEditor.FileEditorManager import com.intellij.openapi.fileTypes.PlainTextFileType import com.intellij.openapi.util.Factory import com.intellij.openapi.util.io.FileUtil +import com.intellij.openapi.vfs.VfsUtil import com.intellij.openapi.vfs.VirtualFile import com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry import com.intellij.psi.* +import com.intellij.psi.impl.PsiManagerEx import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.search.PsiSearchHelper import com.intellij.testFramework.PlatformTestUtil @@ -277,4 +279,27 @@ public class IndexTest extends JavaCodeInsightFixtureTestCase { assertNotNull(findClass("Foo")); } + + public void "test changing a file without psi makes the document committed and updates index"() { + def psiFile = myFixture.addFileToProject("Foo.java", "class Foo {}") + def vFile = psiFile.virtualFile + def scope = GlobalSearchScope.allScope(project) + + FileDocumentManager.instance.getDocument(vFile).text = "import zoo.Zoo; class Foo1 {}" + assert PsiDocumentManager.getInstance(project).uncommittedDocuments + psiFile = null + + PlatformTestUtil.tryGcSoftlyReachableObjects() + + assert !((PsiManagerEx) psiManager).fileManager.getCachedPsiFile(vFile) + + FileDocumentManager.instance.saveAllDocuments() + + VfsUtil.saveText(vFile, "class Foo3 {}") + + assert !PsiDocumentManager.getInstance(project).uncommittedDocuments + + assert JavaPsiFacade.getInstance(project).findClass("Foo3", scope) + } + } diff --git a/java/java-tests/testSrc/com/intellij/index/IndexTestGenerator.scala b/java/java-tests/testSrc/com/intellij/index/IndexTestGenerator.scala index ae6727bd9928..98d0268adfba 100644 --- a/java/java-tests/testSrc/com/intellij/index/IndexTestGenerator.scala +++ b/java/java-tests/testSrc/com/intellij/index/IndexTestGenerator.scala @@ -25,8 +25,11 @@ import org.scalacheck._ import scala.collection.JavaConversions._ /** - * Run this class to generate randomized tests for IDEA VFS/document/PSI/index subsystem interaction using ScalaCheck. - * When a test fails, a test method code (in Groovy) is printed which should be copied to a normal test class and debugged there. + * Run this class to generate randomized tests for IDEA VFS/document/PSI/index subsystem interaction using ScalaCheck.

+ * + * When a test fails, a test method code (in Groovy) is printed which should be copied to a normal test class (IndexTest) + * and debugged there.

+ * * The generated test may contain some excessive declarations and checks that should be corrected manually. * After the fix, that generated test should be renamed according to the underlying issue it found and committed to the repository. *