@@ -19,17 +19,15 @@ import kotlin.test.assertTrue
19
19
20
20
internal const val BANNED_TARGETS_PROPERTY_NAME = " binary.compatibility.validator.klib.targets.blacklist.for.testing"
21
21
22
- private fun KLibVerificationTests.checkKlibDump (buildResult : BuildResult , expectedDumpFileName : String ,
23
- projectName : String = "testproject",
24
- dumpTask : String = ":apiDump",
25
- projectWithMultipleDumps : Boolean = false) {
22
+ private fun KLibVerificationTests.checkKlibDump (
23
+ buildResult : BuildResult ,
24
+ expectedDumpFileName : String ,
25
+ projectName : String = "testproject",
26
+ dumpTask : String = ":apiDump"
27
+ ) {
26
28
buildResult.assertTaskSuccess(dumpTask)
27
29
28
- val generatedDump = if (projectWithMultipleDumps) {
29
- rootProjectAbiDump(target = KLIB_PHONY_TARGET_NAME , project = projectName)
30
- } else {
31
- rootProjectAbiDump(projectName)
32
- }
30
+ val generatedDump = rootProjectAbiDump(projectName)
33
31
assertTrue(generatedDump.exists(), " There are no dumps generated for KLibs" )
34
32
35
33
val expected = readFileList(expectedDumpFileName)
@@ -140,14 +138,10 @@ internal class KLibVerificationTests : BaseKotlinGradleTest() {
140
138
}
141
139
142
140
runner.build().apply {
143
- assertTaskSuccess(" :apiDump" )
144
-
145
- // not common, but built from the common source set
146
- val dump = rootProjectAbiDump(" testproject" )
147
- assertTrue(dump.exists(), " Dump does not exist" )
148
-
149
- val expectedDump = readFileList(" /examples/classes/AnotherBuildConfigLinuxArm64Extra.klib.dump" )
150
- Assertions .assertThat(dump.readText()).isEqualToIgnoringNewLines(expectedDump)
141
+ checkKlibDump(
142
+ this ,
143
+ " /examples/classes/AnotherBuildConfigLinuxArm64Extra.klib.dump"
144
+ )
151
145
}
152
146
}
153
147
@@ -170,8 +164,7 @@ internal class KLibVerificationTests : BaseKotlinGradleTest() {
170
164
}
171
165
172
166
runner.build().apply {
173
- checkKlibDump(this , " /examples/classes/AnotherBuildConfig.klib.dump" ,
174
- projectWithMultipleDumps = false )
167
+ checkKlibDump(this , " /examples/classes/AnotherBuildConfig.klib.dump" )
175
168
176
169
val jvmApiDump = rootProjectDir.resolve(" $API_DIR /testproject.api" )
177
170
assertTrue(jvmApiDump.exists(), " No API dump for JVM" )
@@ -403,7 +396,7 @@ internal class KLibVerificationTests : BaseKotlinGradleTest() {
403
396
}
404
397
405
398
@Test
406
- fun `apiCheck should fail if a target is not supported` () {
399
+ fun `apiCheck should not fail if a target is not supported` () {
407
400
val runner = test {
408
401
settingsGradleKts {
409
402
resolve(" /examples/gradle/settings/settings-name-testproject.gradle.kts" )
@@ -414,15 +407,18 @@ internal class KLibVerificationTests : BaseKotlinGradleTest() {
414
407
kotlin(" TopLevelDeclarations.kt" , " commonMain" ) {
415
408
resolve(" /examples/classes/TopLevelDeclarations.kt" )
416
409
}
417
- abiFile(projectName = " testproject" , target = KLIB_PHONY_TARGET_NAME ) {
410
+ abiFile(projectName = " testproject" ) {
411
+ resolve(" /examples/classes/TopLevelDeclarations.klib.dump" )
418
412
}
419
413
runner {
420
414
arguments.add(" -P$BANNED_TARGETS_PROPERTY_NAME =linuxArm64" )
421
415
arguments.add(" :apiCheck" )
422
416
}
423
417
}
424
418
425
- runner.buildAndFail()
419
+ runner.build().apply {
420
+ assertTaskSuccess(" :apiCheck" )
421
+ }
426
422
}
427
423
428
424
@Test
@@ -501,8 +497,10 @@ internal class KLibVerificationTests : BaseKotlinGradleTest() {
501
497
}
502
498
}
503
499
504
- checkKlibDump(runner.build(), " /examples/classes/TopLevelDeclarations.klib.with.linux.dump" ,
505
- dumpTask = " :klibApiDump" )
500
+ checkKlibDump(
501
+ runner.build(), " /examples/classes/TopLevelDeclarations.klib.with.linux.dump" ,
502
+ dumpTask = " :klibApiDump"
503
+ )
506
504
}
507
505
508
506
@Test
@@ -528,8 +526,10 @@ internal class KLibVerificationTests : BaseKotlinGradleTest() {
528
526
529
527
runner.buildAndFail().apply {
530
528
assertTaskFailure(" :linuxArm64ApiInferAbiDump" )
531
- Assertions .assertThat(output).contains(" The target linuxArm64 is not supported by the host compiler " +
532
- " and there are no targets similar to linuxArm64 to infer a dump from it." )
529
+ Assertions .assertThat(output).contains(
530
+ " The target linuxArm64 is not supported by the host compiler " +
531
+ " and there are no targets similar to linuxArm64 to infer a dump from it."
532
+ )
533
533
}
534
534
}
535
535
@@ -546,16 +546,18 @@ internal class KLibVerificationTests : BaseKotlinGradleTest() {
546
546
resolve(" /examples/classes/TopLevelDeclarations.kt" )
547
547
}
548
548
runner {
549
- arguments.add(" -P$BANNED_TARGETS_PROPERTY_NAME =linuxArm64,linuxX64,mingwX64," +
550
- " androidNativeArm32,androidNativeArm64,androidNativeX64,androidNativeX86" )
549
+ arguments.add(
550
+ " -P$BANNED_TARGETS_PROPERTY_NAME =linuxArm64,linuxX64,mingwX64," +
551
+ " androidNativeArm32,androidNativeArm64,androidNativeX64,androidNativeX86"
552
+ )
551
553
arguments.add(" :klibApiDump" )
552
554
}
553
555
}
554
556
555
557
runner.buildAndFail().apply {
556
- Assertions .assertThat(output).contains(
557
- " is not supported by the host compiler and there are no targets similar to"
558
- )
558
+ Assertions .assertThat(output).contains(
559
+ " is not supported by the host compiler and there are no targets similar to"
560
+ )
559
561
}
560
562
}
561
563
@@ -576,8 +578,10 @@ internal class KLibVerificationTests : BaseKotlinGradleTest() {
576
578
resolve(" /examples/classes/TopLevelDeclarations.klib.dump" )
577
579
}
578
580
runner {
579
- arguments.add(" -P$BANNED_TARGETS_PROPERTY_NAME =linuxArm64,linuxX64,mingwX64," +
580
- " androidNativeArm32,androidNativeArm64,androidNativeX64,androidNativeX86" )
581
+ arguments.add(
582
+ " -P$BANNED_TARGETS_PROPERTY_NAME =linuxArm64,linuxX64,mingwX64," +
583
+ " androidNativeArm32,androidNativeArm64,androidNativeX64,androidNativeX86"
584
+ )
581
585
arguments.add(" :klibApiCheck" )
582
586
}
583
587
}
@@ -607,8 +611,10 @@ internal class KLibVerificationTests : BaseKotlinGradleTest() {
607
611
}
608
612
}
609
613
610
- checkKlibDump(runner.build(), " /examples/classes/AnotherBuildConfig.klib.clash.dump" ,
611
- dumpTask = " :klibApiDump" )
614
+ checkKlibDump(
615
+ runner.build(), " /examples/classes/AnotherBuildConfig.klib.clash.dump" ,
616
+ dumpTask = " :klibApiDump"
617
+ )
612
618
}
613
619
614
620
@Test
@@ -629,8 +635,10 @@ internal class KLibVerificationTests : BaseKotlinGradleTest() {
629
635
}
630
636
}
631
637
632
- checkKlibDump(runner.build(), " /examples/classes/AnotherBuildConfig.klib.custom.dump" ,
633
- dumpTask = " :klibApiDump" )
638
+ checkKlibDump(
639
+ runner.build(), " /examples/classes/AnotherBuildConfig.klib.custom.dump" ,
640
+ dumpTask = " :klibApiDump"
641
+ )
634
642
}
635
643
636
644
@Test
@@ -656,7 +664,9 @@ internal class KLibVerificationTests : BaseKotlinGradleTest() {
656
664
}
657
665
}
658
666
659
- checkKlibDump(runner.build(), " /examples/classes/AnotherBuildConfigLinux.klib.grouping.dump" ,
660
- dumpTask = " :klibApiDump" )
667
+ checkKlibDump(
668
+ runner.build(), " /examples/classes/AnotherBuildConfigLinux.klib.grouping.dump" ,
669
+ dumpTask = " :klibApiDump"
670
+ )
661
671
}
662
672
}
0 commit comments