Add multi-file completion handler tests for FIR code completion

This is a temporary (and dirty) solution to start using those tests as
fast as possible. We certainly need to refactor them so they can be
generated from the testData
This commit is contained in:
Roman Golyshev
2021-03-01 15:19:41 +03:00
parent 73e623b5ac
commit 03a1c6fcca
16 changed files with 52 additions and 3 deletions
@@ -1,3 +1,4 @@
// FIR_COMPARISON
fun foo() {
KtCla<caret>
}
@@ -1,5 +1,6 @@
import pack.KtClass
// FIR_COMPARISON
fun foo() {
KtClass<caret>
}
@@ -1,3 +1,4 @@
// FIR_COMPARISON
fun foo() {
val s = "fo<caret>something"
}
@@ -1,3 +1,4 @@
// FIR_COMPARISON
fun foo() {
val s = "foo.txtsomething"
}
@@ -1,3 +1,4 @@
// FIR_COMPARISON
fun foo() {
val s = "fo<caret>something"
}
@@ -1,3 +1,4 @@
// FIR_COMPARISON
fun foo() {
val s = "foo.txt"
}
@@ -1,3 +1,4 @@
// FIR_COMPARISON
object XXX {
fun authorize(handler: String.() -> Unit) { }
}
@@ -1,5 +1,6 @@
import ppp.globalFun
// FIR_COMPARISON
object XXX {
fun authorize(handler: String.() -> Unit) { }
}
@@ -1,3 +1,4 @@
// FIR_COMPARISON
package some
import test.SomeTestObject
@@ -1,3 +1,4 @@
// FIR_COMPARISON
package some
import test.SomeTestObject
@@ -1,3 +1,4 @@
// FIR_COMPARISON
package classimporttest
fun test() {
@@ -1,3 +1,4 @@
// FIR_COMPARISON
package classimporttest
import forimport.TTTest
@@ -1,3 +1,4 @@
// FIR_COMPARISON
package a
class Goo {
@@ -1,3 +1,4 @@
// FIR_COMPARISON
package a
import a.b.foo
@@ -17,7 +17,7 @@ import org.junit.runner.RunWith
import java.io.File
@RunWith(JUnit3WithIdeaConfigurationRunner::class)
class CompletionMultiFileHandlerTest : KotlinFixtureCompletionBaseTestCase() {
open class CompletionMultiFileHandlerTest : KotlinFixtureCompletionBaseTestCase() {
fun testExtensionFunctionImport() {
doTest()
}
@@ -118,8 +118,11 @@ class CompletionMultiFileHandlerTest : KotlinFixtureCompletionBaseTestCase() {
doTest()
}
fun doTest(completionChar: Char = '\n', vararg extraFileNames: String, tailText: String? = null) {
val fileName = getTestName(false)
private fun doTest(completionChar: Char = '\n', vararg extraFileNames: String, tailText: String? = null) {
doTest(getTestName(false), completionChar, extraFileNames, tailText)
}
open fun doTest(fileName: String, completionChar: Char, extraFileNames: Array<out String>, tailText: String?) {
val defaultFiles = listOf("$fileName-1.kt", "$fileName-2.kt")
val filteredFiles = defaultFiles.filter { File(testDataPath, it).exists() }
@@ -0,0 +1,32 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.idea.completion.test.handlers
import com.intellij.testFramework.LightProjectDescriptor
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
import org.jetbrains.kotlin.test.JUnit3WithIdeaConfigurationRunner
import org.jetbrains.kotlin.test.uitls.IgnoreTests
import org.junit.runner.RunWith
import java.nio.file.Paths
@RunWith(JUnit3WithIdeaConfigurationRunner::class)
class HighLevelCompletionMultifileHandlerTest : CompletionMultiFileHandlerTest() {
/**
* This is a temporary solution! This test should be rewritten to be generated!
*/
override fun doTest(fileName: String, completionChar: Char, extraFileNames: Array<out String>, tailText: String?) {
val testFile = Paths.get(testDataPath, "$fileName-1.kt")
IgnoreTests.runTestIfEnabledByFileDirective(testFile, IgnoreTests.DIRECTIVES.FIR_COMPARISON) {
super.doTest(fileName, completionChar, extraFileNames, tailText)
}
}
override val captureExceptions: Boolean = false
override fun getProjectDescriptor(): LightProjectDescriptor = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
}