-
Notifications
You must be signed in to change notification settings - Fork 391
/
JsIRGradleIntegrationTest.kt
64 lines (52 loc) · 2.47 KB
/
JsIRGradleIntegrationTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package org.jetbrains.dokka.it.gradle
import org.gradle.testkit.runner.TaskOutcome
import org.junit.runners.Parameterized.Parameters
import java.io.File
import kotlin.test.*
class JsIRGradleIntegrationTest(override val versions: BuildVersions) : AbstractGradleIntegrationTest() {
companion object {
@get:JvmStatic
@get:Parameters(name = "{0}")
val versions = TestedVersions.BASE
}
private val ignoredKotlinVersions = setOf(
// There were some breaking refactoring changes in kotlin react wrapper libs in 1.4.0 -> 1.5.0,
// some core react classes were moved from `react-router-dom` to `react` artifacts.
// Writing an integration test project that would work for both 1.4.0 and 1.5.0 would involve
// ugly solutions, so these versions are ignored. Not a big loss given they are deprecated as of this moment.
"1.4.0", "1.4.32", "1.7.0-RC2"
)
@BeforeTest
fun prepareProjectFiles() {
val templateProjectDir = File("projects", "it-js-ir-0")
templateProjectDir.listFiles().orEmpty()
.filter { it.isFile }
.filterNot { it.name == "local.properties" }
.filterNot { it.name.startsWith("gradlew") }
.forEach { topLevelFile -> topLevelFile.copyTo(File(projectDir, topLevelFile.name)) }
File(templateProjectDir, "src").copyRecursively(File(projectDir, "src"))
}
@Test
fun execute() {
if (ignoredKotlinVersions.contains(versions.kotlinVersion)) {
return
}
val reactPropertyArg = TestedVersions.KT_REACT_WRAPPER_MAPPING[versions.kotlinVersion]
?: throw IllegalStateException("Unspecified version of react for kotlin " + versions.kotlinVersion)
val result = createGradleRunner(reactPropertyArg, "dokkaHtml", "-i", "-s").buildRelaxed()
assertEquals(TaskOutcome.SUCCESS, assertNotNull(result.task(":dokkaHtml")).outcome)
val htmlOutputDir = File(projectDir, "build/dokka/html")
assertTrue(htmlOutputDir.isDirectory, "Missing html output directory")
assertTrue(
htmlOutputDir.allHtmlFiles().count() > 0,
"Expected html files in html output directory"
)
htmlOutputDir.allHtmlFiles().forEach { file ->
assertContainsNoErrorClass(file)
assertNoHrefToMissingLocalFileOrDirectory(file)
assertNoUnresolvedLinks(file)
assertNoEmptyLinks(file)
assertNoEmptySpans(file)
}
}
}