mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
[qodana] Fix failing tests [qodana] YAML based profiles should retrieve default inspection profile from profile manager directly Merge-request: IJ-MR-103686 Merged-by: Dmitry Golovinov <Dmitry.Golovinov@jetbrains.com> GitOrigin-RevId: 9ca35539b101aa5eea80efddd6559d756be07b78
59 lines
2.1 KiB
Kotlin
59 lines
2.1 KiB
Kotlin
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
|
package com.intellij.codeInspection.inspectionProfile
|
|
|
|
import com.intellij.codeInspection.ex.ApplicationInspectionProfileManager
|
|
import com.intellij.codeInspection.ex.InspectionProfileImpl
|
|
import com.intellij.openapi.application.PathManager
|
|
import com.intellij.openapi.util.Disposer
|
|
import com.intellij.openapi.util.JDOMUtil
|
|
import com.intellij.openapi.util.io.FileUtil
|
|
import com.intellij.testFramework.LightPlatformTestCase
|
|
import com.intellij.testFramework.TestDataPath
|
|
import junit.framework.TestCase
|
|
import org.jdom.Element
|
|
import java.io.File
|
|
|
|
@TestDataPath("\$CONTENT_ROOT/testData/")
|
|
class YamlInspectionProfileTest: LightPlatformTestCase() {
|
|
|
|
override fun getTestDirectoryName(): String = PathManager.getCommunityHomePath() + "/platform/inspect/testData/"
|
|
|
|
override fun setUp() {
|
|
super.setUp()
|
|
InspectionProfileImpl.INIT_INSPECTIONS = true
|
|
ApplicationInspectionProfileManager.getInstanceImpl().forceInitProfilesInTestUntil(testRootDisposable)
|
|
Disposer.register(testRootDisposable) {
|
|
InspectionProfileImpl.INIT_INSPECTIONS = false
|
|
}
|
|
}
|
|
|
|
fun testBasic(){ checkEffectiveProfile() }
|
|
|
|
fun testBasicGlob(){
|
|
checkEffectiveProfile()
|
|
}
|
|
|
|
fun testChainedInclude(){ checkEffectiveProfile() }
|
|
|
|
fun testChainedOverride(){ checkEffectiveProfile() }
|
|
|
|
fun testGroup(){ checkEffectiveProfile() }
|
|
|
|
fun testPredefinedGroup(){ checkEffectiveProfile() }
|
|
|
|
fun testGroupExclusion(){ checkEffectiveProfile() }
|
|
|
|
private fun checkEffectiveProfile(){
|
|
val fileName = getTestName(true)
|
|
val expectedProfileText = FileUtil.loadFile(File("$testDirectoryName/${fileName}_profile.xml"))
|
|
val effectiveProfile = YamlInspectionProfileImpl.loadFrom(project, "$testDirectoryName/$fileName.yml").buildEffectiveProfile()
|
|
val externalizedText = getExternalizedText(effectiveProfile)
|
|
TestCase.assertEquals(expectedProfileText, externalizedText)
|
|
}
|
|
|
|
private fun getExternalizedText(profile: InspectionProfileImpl): String {
|
|
val element = Element("profile")
|
|
profile.writeExternal(element)
|
|
return JDOMUtil.write(element)
|
|
}
|
|
} |