Add performance tests for typing indentation
This commit is contained in:
@@ -1436,7 +1436,9 @@ fun main(args: Array<String>) {
|
||||
model("addImport", testMethod = "doPerfTest", pattern = KT_WITHOUT_DOTS_IN_NAME)
|
||||
}
|
||||
|
||||
|
||||
testClass<AbstractPerformanceTypingIndentationTest> {
|
||||
model("indentationOnNewline", testMethod = "doPerfTest", pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME)
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("idea/performanceTests/test", "idea/idea-completion/testData") {
|
||||
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.perf
|
||||
|
||||
import com.intellij.application.options.CodeStyle
|
||||
import com.intellij.openapi.actionSystem.IdeActions
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.testFramework.EditorTestUtil
|
||||
import org.jetbrains.kotlin.formatter.FormatSettingsUtil
|
||||
import org.jetbrains.kotlin.idea.test.KotlinLightPlatformCodeInsightTestCase
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import java.io.File
|
||||
|
||||
|
||||
/**
|
||||
* inspired by @see [org.jetbrains.kotlin.formatter.AbstractTypingIndentationTestBase]
|
||||
*/
|
||||
abstract class AbstractPerformanceTypingIndentationTest : KotlinLightPlatformCodeInsightTestCase() {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
val stats: Stats = Stats("typing-indentation")
|
||||
}
|
||||
|
||||
protected fun doPerfTest(filePath: String) {
|
||||
val testName = getTestName(false)
|
||||
val testFileName = filePath.substring(0, filePath.indexOf("."))
|
||||
val testFileExtension = filePath.substring(filePath.lastIndexOf("."))
|
||||
val originFilePath = testFileName + testFileExtension
|
||||
val afterFilePath = "$testFileName.after$testFileExtension"
|
||||
val originalFileText = FileUtil.loadFile(File(originFilePath), true)
|
||||
|
||||
try {
|
||||
val configurator = FormatSettingsUtil.createConfigurator(originalFileText, CodeStyle.getSettings(project))
|
||||
configurator.configureSettings()
|
||||
|
||||
performanceTest<Unit, Unit> {
|
||||
name(testName)
|
||||
stats(stats)
|
||||
setUp {
|
||||
configureByFile(originFilePath)
|
||||
}
|
||||
test {
|
||||
executeAction(IdeActions.ACTION_EDITOR_ENTER)
|
||||
}
|
||||
tearDown {
|
||||
val actualTextWithCaret = StringBuilder(editor.document.text).insert(
|
||||
editor.caretModel.offset,
|
||||
EditorTestUtil.CARET_TAG
|
||||
).toString()
|
||||
|
||||
KotlinTestUtils.assertEqualsToFile(File(afterFilePath), actualTextWithCaret)
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
CodeStyle.getSettings(project).clearCodeStyleSettings()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getTestDataPath(): String = ""
|
||||
}
|
||||
+318
@@ -0,0 +1,318 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.perf;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/testData/indentationOnNewline")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class PerformanceTypingIndentationTestGenerated extends AbstractPerformanceTypingIndentationTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doPerfTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("AfterCatch.kt")
|
||||
public void testAfterCatch() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/AfterCatch.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("AfterClassNameBeforeFun.kt")
|
||||
public void testAfterClassNameBeforeFun() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/AfterClassNameBeforeFun.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("AfterFinally.kt")
|
||||
public void testAfterFinally() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/AfterFinally.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("AfterImport.kt")
|
||||
public void testAfterImport() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/AfterImport.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("AfterTry.kt")
|
||||
public void testAfterTry() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/AfterTry.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInIndentationOnNewline() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/indentationOnNewline"), Pattern.compile("^([^.]+)\\.(kt|kts)$"), null, true);
|
||||
}
|
||||
|
||||
@TestMetadata("Annotation.kt")
|
||||
public void testAnnotation() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/Annotation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("AnnotationInDeclaration.kt")
|
||||
public void testAnnotationInDeclaration() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/AnnotationInDeclaration.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ArgumentListNormalIndent.kt")
|
||||
public void testArgumentListNormalIndent() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/ArgumentListNormalIndent.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("AssignmentAfterEq.kt")
|
||||
public void testAssignmentAfterEq() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/AssignmentAfterEq.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("BinaryWithTypeExpressions.kt")
|
||||
public void testBinaryWithTypeExpressions() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/BinaryWithTypeExpressions.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ConsecutiveCallsAfterDot.kt")
|
||||
public void testConsecutiveCallsAfterDot() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/ConsecutiveCallsAfterDot.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ConsecutiveCallsInSaeCallsMiddle.kt")
|
||||
public void testConsecutiveCallsInSaeCallsMiddle() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/ConsecutiveCallsInSaeCallsMiddle.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ConsecutiveCallsInSafeCallsEnd.kt")
|
||||
public void testConsecutiveCallsInSafeCallsEnd() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/ConsecutiveCallsInSafeCallsEnd.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("DoInFun.kt")
|
||||
public void testDoInFun() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/DoInFun.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("EmptyParameters.kt")
|
||||
public void testEmptyParameters() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/EmptyParameters.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("For.kt")
|
||||
public void testFor() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/For.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("FunctionBlock.kt")
|
||||
public void testFunctionBlock() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/FunctionBlock.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("FunctionWithInference.kt")
|
||||
public void testFunctionWithInference() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/FunctionWithInference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("If.kt")
|
||||
public void testIf() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/If.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InBinaryExpressionInMiddle.kt")
|
||||
public void testInBinaryExpressionInMiddle() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/InBinaryExpressionInMiddle.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InBinaryExpressionUnfinished.kt")
|
||||
public void testInBinaryExpressionUnfinished() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/InBinaryExpressionUnfinished.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InBinaryExpressionUnfinishedInIf.kt")
|
||||
public void testInBinaryExpressionUnfinishedInIf() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/InBinaryExpressionUnfinishedInIf.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InBinaryExpressionsBeforeCloseParenthesis.kt")
|
||||
public void testInBinaryExpressionsBeforeCloseParenthesis() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/InBinaryExpressionsBeforeCloseParenthesis.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InDelegationListAfterColon.kt")
|
||||
public void testInDelegationListAfterColon() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/InDelegationListAfterColon.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InDelegationListAfterComma.kt")
|
||||
public void testInDelegationListAfterComma() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/InDelegationListAfterComma.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InDelegationListNotEmpty.kt")
|
||||
public void testInDelegationListNotEmpty() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/InDelegationListNotEmpty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InEnumAfterSemicolon.kt")
|
||||
public void testInEnumAfterSemicolon() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/InEnumAfterSemicolon.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InEnumInitializerListAfterComma.kt")
|
||||
public void testInEnumInitializerListAfterComma() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/InEnumInitializerListAfterComma.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InEnumInitializerListNotEmpty.kt")
|
||||
public void testInEnumInitializerListNotEmpty() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/InEnumInitializerListNotEmpty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InExpressionsParentheses.kt")
|
||||
public void testInExpressionsParentheses() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/InExpressionsParentheses.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InExpressionsParenthesesBeforeOperand.kt")
|
||||
public void testInExpressionsParenthesesBeforeOperand() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/InExpressionsParenthesesBeforeOperand.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InLabmdaAfterArrow.kt")
|
||||
public void testInLabmdaAfterArrow() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/InLabmdaAfterArrow.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InLambdaAfterArrowWithSpaces.kt")
|
||||
public void testInLambdaAfterArrowWithSpaces() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/InLambdaAfterArrowWithSpaces.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InLambdaBeforeParams.kt")
|
||||
public void testInLambdaBeforeParams() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/InLambdaBeforeParams.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InLambdaInsideChainCallSameLine.kt")
|
||||
public void testInLambdaInsideChainCallSameLine() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/InLambdaInsideChainCallSameLine.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InLambdaInsideChainCallSameLineWithSpaces.kt")
|
||||
public void testInLambdaInsideChainCallSameLineWithSpaces() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/InLambdaInsideChainCallSameLineWithSpaces.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InLambdaInsideChainCallWithNewLine.kt")
|
||||
public void testInLambdaInsideChainCallWithNewLine() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/InLambdaInsideChainCallWithNewLine.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InLambdaInsideChainCallWithNewLineWithSpaces.kt")
|
||||
public void testInLambdaInsideChainCallWithNewLineWithSpaces() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/InLambdaInsideChainCallWithNewLineWithSpaces.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InMultilineLambdaAfterArrow.kt")
|
||||
public void testInMultilineLambdaAfterArrow() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/InMultilineLambdaAfterArrow.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("IsExpressionAfterIs.kt")
|
||||
public void testIsExpressionAfterIs() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/IsExpressionAfterIs.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("KT20783.kt")
|
||||
public void testKT20783() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/KT20783.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ModifierListInUnfinishedDeclaration.kt")
|
||||
public void testModifierListInUnfinishedDeclaration() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/ModifierListInUnfinishedDeclaration.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("MultideclarationAfterEq.kt")
|
||||
public void testMultideclarationAfterEq() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/MultideclarationAfterEq.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("MultideclarationBeforeEq.kt")
|
||||
public void testMultideclarationBeforeEq() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/MultideclarationBeforeEq.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NotFirstParameter.kt")
|
||||
public void testNotFirstParameter() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/NotFirstParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("PropertyWithInference.kt")
|
||||
public void testPropertyWithInference() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/PropertyWithInference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ReturnContinue.kt")
|
||||
public void testReturnContinue() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/ReturnContinue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("SettingAlignMultilineParametersInCalls.kt")
|
||||
public void testSettingAlignMultilineParametersInCalls() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/SettingAlignMultilineParametersInCalls.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("While.kt")
|
||||
public void testWhile() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/While.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/indentationOnNewline/script")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Script extends AbstractPerformanceTypingIndentationTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doPerfTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInScript() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/indentationOnNewline/script"), Pattern.compile("^([^.]+)\\.(kt|kts)$"), null, true);
|
||||
}
|
||||
|
||||
@TestMetadata("ScriptAfterClosingBrace.kts")
|
||||
public void testScriptAfterClosingBrace() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/script/ScriptAfterClosingBrace.kts");
|
||||
}
|
||||
|
||||
@TestMetadata("ScriptAfterExpression.kts")
|
||||
public void testScriptAfterExpression() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/script/ScriptAfterExpression.kts");
|
||||
}
|
||||
|
||||
@TestMetadata("ScriptAfterFun.kts")
|
||||
public void testScriptAfterFun() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/script/ScriptAfterFun.kts");
|
||||
}
|
||||
|
||||
@TestMetadata("ScriptAfterImport.kts")
|
||||
public void testScriptAfterImport() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/script/ScriptAfterImport.kts");
|
||||
}
|
||||
|
||||
@TestMetadata("ScriptBetweenFunctionCalls.kts")
|
||||
public void testScriptBetweenFunctionCalls() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/script/ScriptBetweenFunctionCalls.kts");
|
||||
}
|
||||
|
||||
@TestMetadata("ScriptInsideFun.kts")
|
||||
public void testScriptInsideFun() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/script/ScriptInsideFun.kts");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user