Fix project leaks in tests

This commit is contained in:
Dmitry Jemerov
2017-03-24 15:16:27 +01:00
parent eda3b08c31
commit efa03e7ad8
3 changed files with 13 additions and 2 deletions
@@ -110,6 +110,9 @@ public abstract class KotlinWithLibraryConfigurator implements KotlinProjectConf
dialog.show();
if (!dialog.isOK()) return;
}
else {
dialog.close(0);
}
modulesToConfigure = dialog.getModulesToConfigure();
copyLibraryIntoPath = dialog.getCopyIntoPath();
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
import org.jetbrains.kotlin.test.InTextDirectivesUtils
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.junit.Assert
import kotlin.reflect.KMutableProperty0
abstract class AbstractKotlinTypeAliasByExpansionShortNameIndexTest : KotlinLightCodeInsightFixtureTestCase() {
@@ -30,13 +31,18 @@ abstract class AbstractKotlinTypeAliasByExpansionShortNameIndexTest : KotlinLigh
return KotlinTestUtils.getHomeDirectory() + "/"
}
lateinit var scope: GlobalSearchScope
private lateinit var scope: GlobalSearchScope
override fun setUp() {
super.setUp()
scope = GlobalSearchScope.allScope(project)
}
override fun tearDown() {
(this::scope as KMutableProperty0<GlobalSearchScope?>).set(null)
super.tearDown()
}
override fun getProjectDescriptor() = super.getProjectDescriptorFromTestName()
fun doTest(file: String) {
@@ -33,10 +33,11 @@ import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.KtProperty
import org.jetbrains.kotlin.test.KotlinTestUtils
import kotlin.reflect.KMutableProperty0
class KotlinShortNamesCacheTest : KotlinCodeInsightTestCase() {
lateinit var cacheInstance: PsiShortNamesCache
private lateinit var cacheInstance: PsiShortNamesCache
override fun setUp() {
super.setUp()
@@ -45,6 +46,7 @@ class KotlinShortNamesCacheTest : KotlinCodeInsightTestCase() {
}
override fun tearDown() {
(this::cacheInstance as KMutableProperty0<GlobalSearchScope?>).set(null)
ConfigLibraryUtil.unConfigureKotlinRuntimeAndSdk(myModule, testProjectJdk)
super.tearDown()