[TEST] Introduce test-infrastructure-utils module and extract common test utilities here
This commit is contained in:
+4
-4
@@ -6,11 +6,11 @@
|
||||
package org.jetbrains.kotlin.generators.impl
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import org.jetbrains.kotlin.generators.model.MethodModel
|
||||
import org.jetbrains.kotlin.generators.MethodGenerator
|
||||
import org.jetbrains.kotlin.generators.model.MethodModel
|
||||
import org.jetbrains.kotlin.generators.model.SimpleTestClassModel
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
||||
|
||||
@@ -36,7 +36,7 @@ object SimpleTestClassModelTestAllFilesPresentMethodGenerator : MethodGenerator<
|
||||
val assertTestsPresentStr = if (classModel.targetBackend === TargetBackend.ANY) {
|
||||
String.format(
|
||||
"KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File(\"%s\"), Pattern.compile(\"%s\"), %s, %s%s);",
|
||||
KotlinTestUtils.getFilePath(classModel.rootFile),
|
||||
KtTestUtil.getFilePath(classModel.rootFile),
|
||||
StringUtil.escapeStringCharacters(classModel.filenamePattern.pattern()),
|
||||
excludedArgument,
|
||||
classModel.recursive,
|
||||
@@ -45,7 +45,7 @@ object SimpleTestClassModelTestAllFilesPresentMethodGenerator : MethodGenerator<
|
||||
} else {
|
||||
String.format(
|
||||
"KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File(\"%s\"), Pattern.compile(\"%s\"), %s, %s.%s, %s%s);",
|
||||
KotlinTestUtils.getFilePath(classModel.rootFile),
|
||||
KtTestUtil.getFilePath(classModel.rootFile),
|
||||
StringUtil.escapeStringCharacters(classModel.filenamePattern.pattern()),
|
||||
excludedArgument, TargetBackend::class.java.simpleName, classModel.targetBackend.toString(), classModel.recursive, exclude
|
||||
)
|
||||
|
||||
+3
-3
@@ -5,11 +5,11 @@
|
||||
|
||||
package org.jetbrains.kotlin.generators.impl
|
||||
|
||||
import org.jetbrains.kotlin.generators.model.MethodModel
|
||||
import org.jetbrains.kotlin.generators.MethodGenerator
|
||||
import org.jetbrains.kotlin.generators.model.MethodModel
|
||||
import org.jetbrains.kotlin.generators.model.RunTestMethodModel
|
||||
import org.jetbrains.kotlin.generators.model.SimpleTestMethodModel
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
object SimpleTestMethodGenerator : MethodGenerator<SimpleTestMethodModel>() {
|
||||
@@ -22,7 +22,7 @@ object SimpleTestMethodGenerator : MethodGenerator<SimpleTestMethodModel>() {
|
||||
|
||||
override fun generateBody(method: SimpleTestMethodModel, p: Printer) {
|
||||
with(method) {
|
||||
val filePath = KotlinTestUtils.getFilePath(file) + if (file.isDirectory) "/" else ""
|
||||
val filePath = KtTestUtil.getFilePath(file) + if (file.isDirectory) "/" else ""
|
||||
p.println(RunTestMethodModel.METHOD_NAME, "(\"", filePath, "\");")
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -6,11 +6,11 @@
|
||||
package org.jetbrains.kotlin.generators.impl
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import org.jetbrains.kotlin.generators.model.MethodModel
|
||||
import org.jetbrains.kotlin.generators.MethodGenerator
|
||||
import org.jetbrains.kotlin.generators.model.MethodModel
|
||||
import org.jetbrains.kotlin.generators.model.SingleClassTestModel
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
object SingleClassTestModelAllFilesPresentedMethodGenerator : MethodGenerator<SingleClassTestModel.TestAllFilesPresentMethodModel>() {
|
||||
@@ -37,13 +37,13 @@ object SingleClassTestModelAllFilesPresentedMethodGenerator : MethodGenerator<Si
|
||||
assertTestsPresentStr = if (targetBackend !== TargetBackend.ANY) {
|
||||
String.format(
|
||||
"KotlinTestUtils.assertAllTestsPresentInSingleGeneratedClassWithExcluded(this.getClass(), new File(\"%s\"), Pattern.compile(\"%s\"), %s, %s.%s);",
|
||||
KotlinTestUtils.getFilePath(rootFile), StringUtil.escapeStringCharacters(filenamePattern.pattern()),
|
||||
KtTestUtil.getFilePath(rootFile), StringUtil.escapeStringCharacters(filenamePattern.pattern()),
|
||||
excludedArgument, TargetBackend::class.java.simpleName, targetBackend.toString()
|
||||
)
|
||||
} else {
|
||||
String.format(
|
||||
"KotlinTestUtils.assertAllTestsPresentInSingleGeneratedClassWithExcluded(this.getClass(), new File(\"%s\"), Pattern.compile(\"%s\"), %s);",
|
||||
KotlinTestUtils.getFilePath(rootFile),
|
||||
KtTestUtil.getFilePath(rootFile),
|
||||
StringUtil.escapeStringCharacters(filenamePattern.pattern()),
|
||||
excludedArgument
|
||||
)
|
||||
|
||||
+2
-1
@@ -8,6 +8,7 @@ import com.intellij.openapi.util.io.FileUtil
|
||||
import org.jetbrains.kotlin.generators.util.TestGeneratorUtil.fileNameToJavaIdentifier
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import java.util.regex.Pattern
|
||||
@@ -120,7 +121,7 @@ class SimpleTestClassModel(
|
||||
}
|
||||
|
||||
override val dataString: String
|
||||
get() = KotlinTestUtils.getFilePath(rootFile)
|
||||
get() = KtTestUtil.getFilePath(rootFile)
|
||||
|
||||
override val dataPathRoot: String
|
||||
get() = "\$PROJECT_ROOT"
|
||||
|
||||
+2
-2
@@ -7,8 +7,8 @@ package org.jetbrains.kotlin.generators.model
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import org.jetbrains.kotlin.generators.util.TestGeneratorUtil.escapeForJavaIdentifier
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||
import java.io.File
|
||||
import java.util.regex.Pattern
|
||||
|
||||
@@ -28,7 +28,7 @@ open class SimpleTestMethodModel(
|
||||
override val dataString: String
|
||||
get() {
|
||||
val path = FileUtil.getRelativePath(rootDir, file)!!
|
||||
return KotlinTestUtils.getFilePath(File(path))
|
||||
return KtTestUtil.getFilePath(File(path))
|
||||
}
|
||||
|
||||
override fun shouldBeGenerated(): Boolean {
|
||||
|
||||
+2
-2
@@ -5,8 +5,8 @@
|
||||
package org.jetbrains.kotlin.generators.model
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import java.util.regex.Pattern
|
||||
@@ -54,7 +54,7 @@ class SingleClassTestModel(
|
||||
// There's always one test for checking if all tests are present
|
||||
override val isEmpty: Boolean
|
||||
get() = methods.size <= 1
|
||||
override val dataString: String = KotlinTestUtils.getFilePath(rootFile)
|
||||
override val dataString: String = KtTestUtil.getFilePath(rootFile)
|
||||
override val dataPathRoot: String = "\$PROJECT_ROOT"
|
||||
|
||||
object AllFilesPresentedMethodKind : MethodModel.Kind()
|
||||
|
||||
+2
-1
@@ -19,11 +19,12 @@ package org.jetbrains.kotlin.generators.protobuf
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||
import java.io.File
|
||||
|
||||
class ProtoBufCompareConsistencyTest : TestCase() {
|
||||
fun testAlreadyGenerated() {
|
||||
val testDir = KotlinTestUtils.tmpDir("testDirectory")
|
||||
val testDir = KtTestUtil.tmpDir("testDirectory")
|
||||
val newFile = File(testDir, "ProtoCompareGenerated.kt")
|
||||
GenerateProtoBufCompare.generate(newFile)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user