Minor: fix warnings in AbstractResolveByStubTest

This commit is contained in:
Nikolay Krasko
2019-09-05 17:40:20 +03:00
parent e7d0909979
commit 80b5c76d98
@@ -21,26 +21,22 @@ import java.io.File
abstract class AbstractResolveByStubTest : KotlinLightCodeInsightFixtureTestCase() { abstract class AbstractResolveByStubTest : KotlinLightCodeInsightFixtureTestCase() {
protected fun doTest(testFileName: String) { protected fun doTest(testFileName: String) {
doTest(testFileName, true, true) if (InTextDirectivesUtils.isDirectiveDefined(File(testFileName).readText(), "NO_CHECK_SOURCE_VS_BINARY")) {
}
override fun getProjectDescriptor(): LightProjectDescriptor = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
private fun doTest(path: String, checkPrimaryConstructors: Boolean, checkPropertyAccessors: Boolean) {
if (InTextDirectivesUtils.isDirectiveDefined(File(path).readText(), "NO_CHECK_SOURCE_VS_BINARY")) {
// If NO_CHECK_SOURCE_VS_BINARY is enabled, source vs binary descriptors differ, which means that we should not run this test: // If NO_CHECK_SOURCE_VS_BINARY is enabled, source vs binary descriptors differ, which means that we should not run this test:
// it would compare descriptors resolved from sources (by stubs) with .txt, which describes binary descriptors // it would compare descriptors resolved from sources (by stubs) with .txt, which describes binary descriptors
return return
} }
myFixture.configureByFile(path) myFixture.configureByFile(testFileName)
val shouldFail = getTestName(false) == "ClassWithConstVal" val shouldFail = getTestName(false) == "ClassWithConstVal"
AstAccessControl.testWithControlledAccessToAst(shouldFail, project, testRootDisposable) { AstAccessControl.testWithControlledAccessToAst(shouldFail, project, testRootDisposable) {
performTest(path, checkPrimaryConstructors, checkPropertyAccessors) performTest(testFileName)
} }
} }
private fun performTest(path: String, checkPrimaryConstructors: Boolean, checkPropertyAccessors: Boolean) { override fun getProjectDescriptor(): LightProjectDescriptor = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
private fun performTest(path: String) {
val file = file as KtFile val file = file as KtFile
val module = file.findModuleDescriptor() val module = file.findModuleDescriptor()
val packageViewDescriptor = module.getPackage(FqName("test")) val packageViewDescriptor = module.getPackage(FqName("test"))
@@ -49,13 +45,13 @@ abstract class AbstractResolveByStubTest : KotlinLightCodeInsightFixtureTestCase
val fileToCompareTo = File(FileUtil.getNameWithoutExtension(path) + ".txt") val fileToCompareTo = File(FileUtil.getNameWithoutExtension(path) + ".txt")
RecursiveDescriptorComparator.validateAndCompareDescriptorWithFile( RecursiveDescriptorComparator.validateAndCompareDescriptorWithFile(
packageViewDescriptor, packageViewDescriptor,
RecursiveDescriptorComparator.DONT_INCLUDE_METHODS_OF_OBJECT RecursiveDescriptorComparator.DONT_INCLUDE_METHODS_OF_OBJECT
.filterRecursion(RecursiveDescriptorComparator.SKIP_BUILT_INS_PACKAGES) .filterRecursion(RecursiveDescriptorComparator.SKIP_BUILT_INS_PACKAGES)
.checkPrimaryConstructors(checkPrimaryConstructors) .checkPrimaryConstructors(true)
.checkPropertyAccessors(checkPropertyAccessors) .checkPropertyAccessors(true)
.withValidationStrategy(errorTypesForbidden()), .withValidationStrategy(errorTypesForbidden()),
fileToCompareTo fileToCompareTo
) )
} }
} }