@@ -4,13 +4,10 @@ import dev.adamko.kotlin.binary_compatibility_validator.test.utils.*
44import dev.adamko.kotlin.binary_compatibility_validator.test.utils.api.*
55import io.kotest.assertions.withClue
66import io.kotest.inspectors.shouldForAll
7- import io.kotest.matchers.comparables.shouldBeEqualComparingTo
7+ import io.kotest.matchers.file.shouldBeEmptyDirectory
88import io.kotest.matchers.file.shouldExist
9- import io.kotest.matchers.file.shouldNotExist
109import io.kotest.matchers.shouldBe
1110import io.kotest.matchers.string.shouldContain
12- import java.io.File
13- import java.nio.file.Files
1411import kotlin.io.path.Path
1512import kotlin.io.path.name
1613import org.gradle.testkit.runner.BuildResult
@@ -143,7 +140,7 @@ internal class KlibVerificationTests : BaseKotlinGradleTest() {
143140 jvmApiDump.shouldExist()
144141
145142 val expected = readResourceFile(" /examples/classes/AnotherBuildConfig.dump" )
146- jvmApiDump.readText().invariantNewlines().shouldBeEqualComparingTo (expected)
143+ jvmApiDump.readText().invariantNewlines().shouldBe (expected.invariantNewlines() )
147144 }
148145 }
149146
@@ -386,19 +383,13 @@ internal class KlibVerificationTests : BaseKotlinGradleTest() {
386383 baseProjectSetting()
387384 addToSrcSet(" /examples/classes/TopLevelDeclarations.kt" )
388385 addToSrcSet(" /examples/classes/AnotherBuildConfigLinuxArm64.kt" , " linuxArm64Main" )
389-
390386 disableKLibTargets(" linuxArm64" )
391-
392387 runner {
393- // arguments.add("-P$BANNED_TARGETS_PROPERTY_NAME=linuxArm64")
394388 arguments.add(" :apiDump" )
395389 }
396390 }
397391 runner.build {
398- checkKLibDump(
399- " /examples/classes/TopLevelDeclarations.klib.with.linux.dump" ,
400- dumpTask = " :apiDump"
401- )
392+ checkKLibDump(" /examples/classes/TopLevelDeclarations.klib.with.linux.dump" )
402393 }
403394 }
404395
@@ -419,14 +410,11 @@ internal class KlibVerificationTests : BaseKotlinGradleTest() {
419410
420411 runner {
421412// arguments.add("-P$BANNED_TARGETS_PROPERTY_NAME=linux")
422- arguments.add(" :klibApiDump " )
413+ arguments.add(" :apiDump " )
423414 }
424415 }
425416 runner.build {
426- checkKLibDump(
427- " /examples/classes/TopLevelDeclarations.klib.with.guessed.linux.dump" ,
428- dumpTask = " :klibApiDump"
429- )
417+ checkKLibDump(" /examples/classes/TopLevelDeclarations.klib.with.guessed.linux.dump" )
430418 }
431419 }
432420
@@ -446,7 +434,7 @@ internal class KlibVerificationTests : BaseKotlinGradleTest() {
446434
447435 runner {
448436// arguments.add("-P$BANNED_TARGETS_PROPERTY_NAME=linuxArm64")
449- arguments.add(" :klibApiDump " )
437+ arguments.add(" :apiDump " )
450438 }
451439 }
452440
@@ -475,7 +463,7 @@ internal class KlibVerificationTests : BaseKotlinGradleTest() {
475463// "-P$BANNED_TARGETS_PROPERTY_NAME=linuxArm64,linuxX64,mingwX64," +
476464// "androidNativeArm32,androidNativeArm64,androidNativeX64,androidNativeX86"
477465// )
478- arguments.add(" :klibApiDump " )
466+ arguments.add(" :apiDump " )
479467 }
480468 }
481469
@@ -507,7 +495,7 @@ internal class KlibVerificationTests : BaseKotlinGradleTest() {
507495// "-P$BANNED_TARGETS_PROPERTY_NAME=linuxArm64,linuxX64,mingwX64," +
508496// "androidNativeArm32,androidNativeArm64,androidNativeX64,androidNativeX86"
509497// )
510- arguments.add(" :klibApiCheck " )
498+ arguments.add(" :apiCheck " )
511499 }
512500 }
513501
@@ -553,15 +541,12 @@ internal class KlibVerificationTests : BaseKotlinGradleTest() {
553541 }
554542 addToSrcSet(" /examples/classes/AnotherBuildConfig.kt" )
555543 runner {
556- arguments.add(" :klibApiDump " )
544+ arguments.add(" :apiDump " )
557545 }
558546 }
559547
560548 runner.build {
561- checkKLibDump(
562- " /examples/classes/AnotherBuildConfig.klib.custom.dump" ,
563- dumpTask = " :klibApiDump"
564- )
549+ checkKLibDump(" /examples/classes/AnotherBuildConfig.klib.custom.dump" )
565550 }
566551 }
567552
@@ -579,10 +564,7 @@ internal class KlibVerificationTests : BaseKotlinGradleTest() {
579564 }
580565 }
581566 runner.build {
582- checkKLibDump(
583- " /examples/classes/AnotherBuildConfigLinux.klib.grouping.dump" ,
584- dumpTask = " :apiDump"
585- )
567+ checkKLibDump(" /examples/classes/AnotherBuildConfigLinux.klib.grouping.dump" )
586568 }
587569 }
588570
@@ -637,16 +619,9 @@ internal class KlibVerificationTests : BaseKotlinGradleTest() {
637619 }
638620
639621 // Update the source file by adding a declaration
640- val updatedSourceFile = File (
641- this ::class .java.getResource(
642- " /examples/classes/AnotherBuildConfigModified.kt"
643- )!! .toURI()
644- )
645- val existingSource = runner.projectDir.resolve(
646- " src/commonMain/kotlin/AnotherBuildConfig.kt"
647- )
648- Files .write(existingSource.toPath(), updatedSourceFile.readBytes())
649-
622+ val updatedSourceFile = readResourceFile(" /examples/classes/AnotherBuildConfigModified.kt" )
623+ val existingSource = runner.projectDir.resolve(" src/commonMain/kotlin/AnotherBuildConfig.kt" )
624+ existingSource.writeText(updatedSourceFile)
650625
651626 runner.build {
652627 checkKLibDump(" /examples/classes/AnotherBuildConfigModified.klib.dump" )
@@ -666,20 +641,13 @@ internal class KlibVerificationTests : BaseKotlinGradleTest() {
666641 runner.build {
667642 checkKLibDump(" /examples/classes/AnotherBuildConfig.klib.dump" )
668643 // Update the source file by adding a declaration
669- val updatedSourceFile = File (
670- this ::class .java.getResource(
671- " /examples/classes/AnotherBuildConfigLinuxArm64.kt"
672- )!! .toURI()
673- )
674- val existingSource = runner.projectDir.resolve(
675- " src/linuxArm64Main/kotlin/AnotherBuildConfigLinuxArm64.kt"
676- )
644+ val updatedSourceFile = readResourceFile(" /examples/classes/AnotherBuildConfigLinuxArm64.kt" )
645+ val existingSource =
646+ runner.projectDir.resolve(" src/linuxArm64Main/kotlin/AnotherBuildConfigLinuxArm64.kt" )
677647 existingSource.parentFile.mkdirs()
678- Files .write(existingSource.toPath(), updatedSourceFile.readBytes())
679-
648+ existingSource.writeText(updatedSourceFile)
680649
681650 runner.build {
682-
683651 checkKLibDump(" /examples/classes/AnotherBuildConfigLinuxArm64Extra.klib.dump" )
684652 }
685653 }
@@ -702,18 +670,12 @@ internal class KlibVerificationTests : BaseKotlinGradleTest() {
702670 }
703671
704672 // Update the source file by adding a declaration
705- val updatedSourceFile = File (
706- this ::class .java.getResource(
707- " /examples/classes/AnotherBuildConfigModified.kt"
708- )!! .toURI()
709- )
710- val existingSource = runner.projectDir.resolve(
711- " src/commonMain/kotlin/AnotherBuildConfig.kt"
712- )
713- Files .write(existingSource.toPath(), updatedSourceFile.readBytes())
673+ val updatedSourceFile = readResourceFile(" /examples/classes/AnotherBuildConfigModified.kt" )
674+ val existingSource = runner.projectDir.resolve(" src/commonMain/kotlin/AnotherBuildConfig.kt" )
675+ existingSource.writeText(updatedSourceFile)
714676
715677 runner.buildAndFail {
716- shouldHaveTaskWithOutcome(" :klibApiCheck " , FAILED )
678+ shouldHaveTaskWithOutcome(" :apiCheck " , FAILED )
717679 }
718680 }
719681
@@ -746,8 +708,8 @@ internal class KlibVerificationTests : BaseKotlinGradleTest() {
746708 }
747709
748710 runner.build {
749- shouldHaveTaskWithOutcome(" :klibApiCheck " , SKIPPED )
750- rootProjectApiDump.parentFile.shouldNotExist ()
711+ shouldHaveTaskWithOutcome(" :apiDump " , SUCCESS )
712+ rootProjectApiDump.parentFile.shouldBeEmptyDirectory ()
751713 }
752714 }
753715
@@ -777,7 +739,7 @@ internal class KlibVerificationTests : BaseKotlinGradleTest() {
777739 }
778740 }
779741 runner.build {
780- shouldHaveRunTask(" :apiCheck" , SUCCESS )
742+ shouldHaveRunTask(" :apiCheck" , SKIPPED )
781743 }
782744 }
783745
@@ -819,10 +781,9 @@ internal class KlibVerificationTests : BaseKotlinGradleTest() {
819781 private fun BuildResult.checkKLibDump (
820782 expectedDumpFileName : String ,
821783 projectName : String = "testproject",
822- dumpTask : String = ":apiDump",
823784 ) {
824785 withClue(output) {
825- shouldHaveRunTask(dumpTask , SUCCESS )
786+ shouldHaveRunTask(" :apiDump " , SUCCESS )
826787
827788 val generatedDump = rootProjectAbiDump(projectName)
828789
@@ -840,12 +801,13 @@ internal class KlibVerificationTests : BaseKotlinGradleTest() {
840801 private fun BaseKotlinScope.disableKLibTargets (vararg targetNames : String ) {
841802 buildGradleKts {
842803 val disabledTargets =
843- targetNames.joinToString(separator = " , " , prefix = " setOf( " , postfix = " ) " )
804+ targetNames.joinToString(" , " ) { " \" $it \" " }
844805 addText(
845806 """
846- |binaryCompatibilityValidator.targets.withType<BCVKLibTarget>()
847- | .matching { it.targetName in $disabledTargets }
848- | .configureEach { this.supportedByCurrentHost.set(false) }
807+ |binaryCompatibilityValidator.targets
808+ | .withType<dev.adamko.kotlin.binary_compatibility_validator.targets.BCVKLibTarget>()
809+ | .matching { it.targetName in setOf($disabledTargets ) }
810+ | .configureEach { supportedByCurrentHost.set(false) }
849811 |
850812 """ .trimMargin()
851813 )
0 commit comments