@@ -13,119 +13,95 @@ import io.kotest.matchers.string.shouldNotContain
13
13
14
14
class KotlinMultiplatformFunctionalTest : FunSpec ({
15
15
16
- val kotlinVersionsToTest = listOf(
17
- "1.8.22",
18
- "1.9.10",
19
- "1.9.20-dev-9102",
20
- )
21
-
22
- for (kotlinVersion in kotlinVersionsToTest) {
23
- testKotlinMultiplatformProject(kotlinVersion)
24
- }
25
- })
16
+ context("when dokkatoo generates all formats") {
17
+ val project = initKotlinMultiplatformProject()
18
+
19
+ project.runner
20
+ .addArguments(
21
+ "clean",
22
+ ":dokkatooGeneratePublicationHtml",
23
+ "--stacktrace",
24
+ )
25
+ .forwardOutput()
26
+ .build {
27
+ test("expect build is successful") {
28
+ output shouldContain " BUILD SUCCESSFUL"
29
+ }
30
+ }
26
31
32
+ test("expect all dokka workers are successful") {
33
+ project
34
+ .findFiles { it.name == " dokka-worker.log" }
35
+ .shouldBeSingleton { dokkaWorkerLog ->
36
+ dokkaWorkerLog.shouldBeAFile()
37
+ dokkaWorkerLog.readText().shouldNotContainAnyOf(
38
+ "[ERROR ]",
39
+ "[WARN ]",
40
+ )
41
+ }
42
+ }
27
43
28
- private fun FunSpec.testKotlinMultiplatformProject (
29
- kotlinVersion : String ,
30
- ): Unit = context(" when dokkatoo generates all formats for Kotlin v$kotlinVersion project" ) {
31
- val project = initKotlinMultiplatformProject(kotlinVersion)
44
+ context("expect HTML site is generated") {
32
45
33
- project.runner
34
- .addArguments(
35
- " clean" ,
36
- " :dokkatooGeneratePublicationHtml" ,
37
- " --stacktrace" ,
38
- )
39
- .forwardOutput()
40
- .build {
41
- test(" expect build is successful" ) {
42
- output shouldContain " BUILD SUCCESSFUL"
46
+ test("with expected HTML files") {
47
+ project.projectDir.resolve("build/dokka/html/index.html").shouldBeAFile()
48
+ project.projectDir.resolve("build/dokka/html/com/project/hello/Hello .html")
49
+ .shouldBeAFile()
43
50
}
44
- }
45
51
46
- test(" expect all dokka workers are successful" ) {
47
- project
48
- .findFiles { it.name == " dokka-worker.log" }
49
- .shouldBeSingleton { dokkaWorkerLog ->
50
- dokkaWorkerLog.shouldBeAFile()
51
- dokkaWorkerLog.readText().shouldNotContainAnyOf(
52
- " [ERROR]" ,
53
- " [WARN]" ,
54
- )
52
+ test("and dokka_parameters.json is generated") {
53
+ project.projectDir.resolve("build/dokka/html/dokka_parameters.json")
54
+ .shouldBeAFile()
55
55
}
56
- }
57
-
58
- context(" expect HTML site is generated" ) {
59
56
60
- test(" with expected HTML files" ) {
61
- project.projectDir.resolve(" build/dokka/html/index.html" ).shouldBeAFile()
62
- project.projectDir.resolve(" build/dokka/html/com/project/hello/Hello.html" )
63
- .shouldBeAFile()
64
- }
65
-
66
- test(" and dokka_parameters.json is generated" ) {
67
- project.projectDir.resolve(" build/dokka/html/dokka_parameters.json" )
68
- .shouldBeAFile()
69
- }
70
-
71
- test(" with element-list" ) {
72
- project.projectDir.resolve(" build/dokka/html/test/package-list" ).shouldBeAFile()
73
- project.projectDir.resolve(" build/dokka/html/test/package-list" ).toFile().readText()
74
- .sortLines()
75
- .shouldContain( /* language=text */ """
76
- |${' $' } dokka.format:html-v1
77
- |${' $' } dokka.linkExtension:html
78
- |${' $' } dokka.location:com.project////PointingToDeclaration/test/com.project/index.html
79
- |${' $' } dokka.location:com.project//goodbye/#kotlinx.serialization.json.JsonObject/PointingToDeclaration/test/com.project/goodbye.html
80
- |${' $' } dokka.location:com.project/Hello///PointingToDeclaration/test/com.project/-hello/index.html
81
- |${' $' } dokka.location:com.project/Hello/Hello/#/PointingToDeclaration/test/com.project/-hello/-hello.html
82
- |${' $' } dokka.location:com.project/Hello/sayHello/#kotlinx.serialization.json.JsonObject/PointingToDeclaration/test/com.project/-hello/say-hello.html
83
- |com.project
84
- """ .trimMargin()
85
- )
86
- }
57
+ test("with element-list") {
58
+ project.projectDir.resolve("build/dokka/html/test/package-list").shouldBeAFile()
59
+ project.projectDir.resolve("build/dokka/html/test/package-list").toFile().readText()
60
+ .sortLines()
61
+ .shouldContain( /* language=text */ """
62
+ |${'$'}dokka.format:html-v1
63
+ |${'$'}dokka.linkExtension:html
64
+ |${'$'}dokka.location:com.project////PointingToDeclaration /test/com.project/index.html
65
+ |${'$'}dokka.location:com.project//goodbye/#kotlinx.serialization.json.JsonObject /PointingToDeclaration /test/com.project/goodbye.html
66
+ |${'$'}dokka.location:com.project/Hello ///PointingToDeclaration /test/com.project/-hello/index.html
67
+ |${'$'}dokka.location:com.project/Hello /Hello /#/PointingToDeclaration /test/com.project/-hello/-hello.html
68
+ |${'$'}dokka.location:com.project/Hello /sayHello/#kotlinx.serialization.json.JsonObject /PointingToDeclaration /test/com.project/-hello/say-hello.html
69
+ |com.project
70
+ """.trimMargin()
71
+ )
72
+ }
87
73
88
- test(" expect no 'unknown class' message in HTML files" ) {
89
- val htmlFiles = project.projectDir.toFile()
90
- .resolve(" build/dokka/html" )
91
- .walk()
92
- .filter { it.isFile && it.extension == " html" }
74
+ test("expect no 'unknown class' message in HTML files") {
75
+ val htmlFiles = project.projectDir.toFile()
76
+ .resolve("build/dokka/html")
77
+ .walk()
78
+ .filter { it.isFile && it.extension == " html" }
93
79
94
- htmlFiles.shouldNotBeEmpty()
80
+ htmlFiles.shouldNotBeEmpty()
95
81
96
- htmlFiles.forEach { htmlFile ->
97
- val relativePath = htmlFile.relativeTo(project.projectDir.toFile())
98
- withClue(" $relativePath should not contain Error class: unknown class" ) {
99
- htmlFile.useLines { lines ->
100
- lines.shouldForAll { line -> line.shouldNotContain(" Error class: unknown class" ) }
82
+ htmlFiles.forEach { htmlFile ->
83
+ val relativePath = htmlFile.relativeTo(project.projectDir.toFile())
84
+ withClue("$relativePath should not contain Error class: unknown class") {
85
+ htmlFile.useLines { lines ->
86
+ lines.shouldForAll { line -> line.shouldNotContain("Error class: unknown class") }
87
+ }
101
88
}
102
89
}
103
90
}
104
91
}
105
92
}
106
- }
93
+ })
107
94
108
95
109
96
private fun initKotlinMultiplatformProject (
110
- kotlinVersion : String ,
111
97
config : GradleProjectTest .() -> Unit = {},
112
98
): GradleProjectTest {
113
- return gradleKtsProjectTest(" kotlin-multiplatform-project-v $kotlinVersion " ) {
99
+ return gradleKtsProjectTest(" kotlin-multiplatform-project" ) {
114
100
115
- settingsGradleKts = settingsGradleKts.replace(
116
- """
117
- |pluginManagement {
118
- | repositories {
119
- """ .trimMargin(),
120
- """
121
- |pluginManagement {
122
- | repositories {
123
- | maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap")
124
- """ .trimMargin(),
125
- )
126
101
settingsGradleKts + = """
127
102
|
128
103
|dependencyResolutionManagement {
104
+ |
129
105
| repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
130
106
|
131
107
| repositories {
@@ -155,40 +131,14 @@ private fun initKotlinMultiplatformProject(
155
131
| }
156
132
| filter { includeGroup("com.yarnpkg") }
157
133
| }
158
- | maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap")
159
- |
160
- | // workaround for https://youtrack.jetbrains.com/issue/KT-51379
161
- | exclusiveContent {
162
- | forRepository {
163
- | ivy("https://download.jetbrains.com/kotlin/native/builds") {
164
- | name = "Kotlin Native"
165
- | patternLayout {
166
- | listOf(
167
- | "macos-x86_64",
168
- | "macos-aarch64",
169
- | "osx-x86_64",
170
- | "osx-aarch64",
171
- | "linux-x86_64",
172
- | "windows-x86_64",
173
- | ).forEach { os ->
174
- | listOf("dev", "releases").forEach { stage ->
175
- artifact("${' $' } stage/[revision]/${' $' } os/[artifact]-[revision].[ext]")
176
- | }
177
- | }
178
- | }
179
- | metadataSources { artifact() }
180
- | }
181
- | }
182
- | filter { includeModuleByRegex(".*", ".*kotlin-native-prebuilt.*") }
183
- | }
184
134
| }
185
135
|}
186
136
|
187
137
""" .trimMargin()
188
138
189
139
buildGradleKts = """
190
140
|plugins {
191
- | kotlin("multiplatform") version "$kotlinVersion "
141
+ | kotlin("multiplatform") version "1.8.22 "
192
142
| id("dev.adamko.dokkatoo") version "${DokkatooConstants .DOKKATOO_VERSION } "
193
143
|}
194
144
|
@@ -197,11 +147,6 @@ private fun initKotlinMultiplatformProject(
197
147
| js(IR) {
198
148
| browser()
199
149
| }
200
- | linuxX64()
201
- | macosX64()
202
- | macosArm64()
203
- | iosX64()
204
- | mingwX64()
205
150
|
206
151
| sourceSets {
207
152
| commonMain {
@@ -267,30 +212,34 @@ private fun initKotlinMultiplatformProject(
267
212
)
268
213
}
269
214
270
- listOf (
271
- " jvm" ,
272
- " js" ,
273
- " linuxX64" ,
274
- " macosX64" ,
275
- " macosArm64" ,
276
- " iosX64" ,
277
- " mingwX64" ,
278
- ).forEach { target ->
215
+ dir(" src/jvmMain/kotlin/" ) {
216
+ createKotlinFile(
217
+ " goodbyeJvm.kt" ,
218
+ """
219
+ |package com.project
220
+ |
221
+ |import kotlinx.serialization.json.JsonObject
222
+ |
223
+ |/** JVM implementation - prints `goodbye` and [json] to the console */
224
+ |actual fun goodbye(json: JsonObject) = println("[JVM] goodbye ${' $' } json")
225
+ |
226
+ """ .trimMargin()
227
+ )
228
+ }
279
229
280
- dir(" src/${target} Main /kotlin/" ) {
281
- createKotlinFile(
282
- " goodbye_ ${target} .kt" ,
283
- """
230
+ dir(" src/jsMain /kotlin/" ) {
231
+ createKotlinFile(
232
+ " goodbyeJs .kt" ,
233
+ """
284
234
|package com.project
285
235
|
286
236
|import kotlinx.serialization.json.JsonObject
287
237
|
288
- |/** $target implementation - prints `goodbye` and [json] to the console */
289
- |actual fun goodbye(json: JsonObject) = println("[target ] goodbye ${' $' } json")
238
+ |/** JS implementation - prints `goodbye` and [json] to the console */
239
+ |actual fun goodbye(json: JsonObject) = println("[JS ] goodbye ${' $' } json")
290
240
|
291
241
""" .trimMargin()
292
- )
293
- }
242
+ )
294
243
}
295
244
296
245
config()
0 commit comments