diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2020-08-14 13:38:36 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-08-19 13:34:10 +0200 |
commit | a547235b41cb3c5d8a2dfb50923bf1ec2d3cd620 (patch) | |
tree | 0528e91a2134d440cda1e781540c5264d53ced4b /integration-tests | |
parent | 97275264d7c39afde6c6a1511e7ad499430ca594 (diff) | |
download | dokka-a547235b41cb3c5d8a2dfb50923bf1ec2d3cd620.tar.gz dokka-a547235b41cb3c5d8a2dfb50923bf1ec2d3cd620.tar.bz2 dokka-a547235b41cb3c5d8a2dfb50923bf1ec2d3cd620.zip |
Implement ignoring known unresolved links in integration tests
Diffstat (limited to 'integration-tests')
2 files changed, 9 insertions, 17 deletions
diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Android0GradleIntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Android0GradleIntegrationTest.kt index c24ca75b..c13fcf14 100644 --- a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Android0GradleIntegrationTest.kt +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Android0GradleIntegrationTest.kt @@ -64,7 +64,7 @@ class Android0GradleIntegrationTest(override val versions: BuildVersions) : Abst htmlOutputDir.allHtmlFiles().forEach { file -> assertContainsNoErrorClass(file) - assertNoUnresolvedLinksIgnoringKnown(file) + assertNoUnresolvedLinks(file, knownUnresolvedDRIs) assertNoHrefToMissingLocalFileOrDirectory(file) assertNoEmptyLinks(file) } @@ -89,21 +89,11 @@ class Android0GradleIntegrationTest(override val versions: BuildVersions) : Abst } } - // TODO: use [assertNoUnresolvedLinks] instead when https://github.com/Kotlin/dokka/issues/1306 is closed - private fun assertNoUnresolvedLinksIgnoringKnown(file: File) { - val knownUnresolvedDRIs = setOf( + // TODO: remove this list when https://github.com/Kotlin/dokka/issues/1306 is closed + private val knownUnresolvedDRIs = setOf( "it.android/IntegrationTestActivity/findViewById/#kotlin.Int/PointingToGenericParameters(0)/", "it.android/IntegrationTestActivity/getExtraData/#java.lang.Class[TypeParam(bounds=[androidx.core.app.ComponentActivity.ExtraData])]/PointingToGenericParameters(0)/", "it.android/IntegrationTestActivity/getSystemService/#java.lang.Class[TypeParam(bounds=[kotlin.Any])]/PointingToGenericParameters(0)/", "it.android/IntegrationTestActivity/requireViewById/#kotlin.Int/PointingToGenericParameters(0)/" ) - val fileText = file.readText() - val regex = Regex("""data-unresolved-link="\[(.+?(?=]"))""") - val match = regex.findAll(fileText).map { it.groups[1]!!.value } - - assertTrue( - match.filterNot { it in knownUnresolvedDRIs }.toList().isEmpty(), - "Unexpected unresolved link in ${file.path}\n" + fileText - ) - } } diff --git a/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/AbstractIntegrationTest.kt b/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/AbstractIntegrationTest.kt index c2f4f49b..04ae4a88 100644 --- a/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/AbstractIntegrationTest.kt +++ b/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/AbstractIntegrationTest.kt @@ -42,11 +42,13 @@ abstract class AbstractIntegrationTest { ) } - protected fun assertNoUnresolvedLinks(file: File) { - val regex = Regex("data-unresolved-link") + protected fun assertNoUnresolvedLinks(file: File, exceptions: Set<String> = emptySet()) { val fileText = file.readText() - assertFalse( - fileText.contains(regex), + val regex = Regex("""data-unresolved-link="\[(.+?(?=]"))""") + val match = regex.findAll(fileText).map { it.groups[1]!!.value } + + assertTrue( + match.filterNot { it in exceptions }.toList().isEmpty(), "Unexpected unresolved link in ${file.path}\n" + fileText ) } |