From 84574c4b3f0058e5155e20dfd485918c04bdb4ba Mon Sep 17 00:00:00 2001 From: Alex Plate Date: Thu, 18 Aug 2022 14:45:38 +0300 Subject: [PATCH] [Workspace Model] Disable generator version check in tests where you do generate entities GitOrigin-RevId: 3ed8fbeb4c3b646bdff2355b11bd8214677c8e9a --- .../storage/generatedCodeCompatibility.kt | 26 ++++++++++--------- .../IntellijEntitiesGenerationTest.kt | 18 ++++++++++++- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/platform/workspaceModel/storage/src/com/intellij/workspaceModel/storage/generatedCodeCompatibility.kt b/platform/workspaceModel/storage/src/com/intellij/workspaceModel/storage/generatedCodeCompatibility.kt index 951ae25f7172..4541fd2d6656 100644 --- a/platform/workspaceModel/storage/src/com/intellij/workspaceModel/storage/generatedCodeCompatibility.kt +++ b/platform/workspaceModel/storage/src/com/intellij/workspaceModel/storage/generatedCodeCompatibility.kt @@ -16,6 +16,7 @@ object CodeGeneratorVersions { var checkApiInInterface = true var checkApiInImpl = true + var checkImplInImpl = true } @Target(AnnotationTarget.CLASS) @@ -65,18 +66,19 @@ object GeneratedCodeCompatibilityChecker { } } - // Check that impl class has the correct impl version - val entityImplImplVersion = implAnnotations.filterIsInstance().singleOrNull()?.version - ?: error("Generated class '$implClass' doesn't have an impl version marker. " + - "You should regenerate the code of your entities") - assert(entityImplImplVersion == CodeGeneratorVersions.IMPL_VERSION) { - """ - Current IMPL version of the generator is '${CodeGeneratorVersions.IMPL_VERSION}', - but the generated code is marked as version '$entityImplImplVersion'. - Please, regenerate your entities. - - Checked entity: $implClass - """.trimIndent() + if (CodeGeneratorVersions.checkImplInImpl) { // Check that impl class has the correct impl version + val entityImplImplVersion = implAnnotations.filterIsInstance().singleOrNull()?.version + ?: error("Generated class '$implClass' doesn't have an impl version marker. " + + "You should regenerate the code of your entities") + assert(entityImplImplVersion == CodeGeneratorVersions.IMPL_VERSION) { + """ + Current IMPL version of the generator is '${CodeGeneratorVersions.IMPL_VERSION}', + but the generated code is marked as version '$entityImplImplVersion'. + Please, regenerate your entities. + + Checked entity: $implClass + """.trimIndent() + } } } } diff --git a/plugins/devkit/intellij.devkit.workspaceModel/tests/testSrc/com/intellij/devkit/workspaceModel/IntellijEntitiesGenerationTest.kt b/plugins/devkit/intellij.devkit.workspaceModel/tests/testSrc/com/intellij/devkit/workspaceModel/IntellijEntitiesGenerationTest.kt index 9fd67e453f0d..af9d6584ac34 100644 --- a/plugins/devkit/intellij.devkit.workspaceModel/tests/testSrc/com/intellij/devkit/workspaceModel/IntellijEntitiesGenerationTest.kt +++ b/plugins/devkit/intellij.devkit.workspaceModel/tests/testSrc/com/intellij/devkit/workspaceModel/IntellijEntitiesGenerationTest.kt @@ -7,10 +7,26 @@ import com.intellij.openapi.vfs.VirtualFileFilter import com.intellij.openapi.vfs.VirtualFileManager import com.intellij.testFramework.PlatformTestUtil import com.intellij.util.SystemProperties +import com.intellij.workspaceModel.storage.CodeGeneratorVersions import java.io.File import java.nio.file.Path class IntellijEntitiesGenerationTest : CodeGenerationTestBase() { + + override fun setUp() { + CodeGeneratorVersions.checkApiInInterface = false + CodeGeneratorVersions.checkApiInImpl = false + CodeGeneratorVersions.checkImplInImpl = false + super.setUp() + } + + override fun tearDown() { + super.tearDown() + CodeGeneratorVersions.checkApiInInterface = true + CodeGeneratorVersions.checkApiInImpl = true + CodeGeneratorVersions.checkImplInImpl = true + } + private enum class IntellijEntitiesPackage(val apiRootRelativePath: String, val implRootRelativePath: String, val pathToPackage: String, val keepPropertiesWithUnknownType: Boolean = false) { Bridges("platform/workspaceModel/storage/src", "platform/workspaceModel/storage/gen", @@ -19,7 +35,7 @@ class IntellijEntitiesGenerationTest : CodeGenerationTestBase() { "plugins/eclipse/gen", "org/jetbrains/idea/eclipse/workspaceModel"), Tests("platform/workspaceModel/storage/testEntities/testSrc", - "platform/workspaceModel/storage/testEntities/gen", + "platform/workspaceModel/storage/testEntities/gen", "com/intellij/workspaceModel/storage/entities/test/api", true); val apiRootPath: Path