-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure output directory for dumps (#170)
* Support output directory configuration Fixes #127 --------- Co-authored-by: Vsevolod Tolstopyatov <[email protected]>
- Loading branch information
Showing
9 changed files
with
234 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
160 changes: 160 additions & 0 deletions
160
src/functionalTest/kotlin/kotlinx/validation/test/OutputDirectoryTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
/* | ||
* Copyright 2016-2024 JetBrains s.r.o. | ||
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file. | ||
*/ | ||
|
||
package kotlinx.validation.test | ||
|
||
import kotlinx.validation.api.* | ||
import kotlinx.validation.api.buildGradleKts | ||
import kotlinx.validation.api.resolve | ||
import kotlinx.validation.api.test | ||
import org.assertj.core.api.Assertions | ||
import org.junit.Test | ||
import kotlin.test.assertTrue | ||
|
||
class OutputDirectoryTests : BaseKotlinGradleTest() { | ||
@Test | ||
fun dumpIntoCustomDirectory() { | ||
val runner = test { | ||
buildGradleKts { | ||
resolve("/examples/gradle/base/withPlugin.gradle.kts") | ||
resolve("/examples/gradle/configuration/outputDirectory/different.gradle.kts") | ||
} | ||
|
||
kotlin("AnotherBuildConfig.kt") { | ||
resolve("/examples/classes/AnotherBuildConfig.kt") | ||
} | ||
dir("api") { | ||
file("letMeBe.txt") { | ||
} | ||
} | ||
|
||
runner { | ||
arguments.add(":apiDump") | ||
} | ||
} | ||
|
||
runner.build().apply { | ||
assertTaskSuccess(":apiDump") | ||
|
||
val dumpFile = rootProjectDir.resolve("custom").resolve("${rootProjectDir.name}.api") | ||
assertTrue(dumpFile.exists(), "api dump file ${dumpFile.path} should exist") | ||
|
||
val expected = readFileList("/examples/classes/AnotherBuildConfig.dump") | ||
Assertions.assertThat(dumpFile.readText()).isEqualToIgnoringNewLines(expected) | ||
|
||
val fileInsideDir = rootProjectDir.resolve("api").resolve("letMeBe.txt") | ||
assertTrue(fileInsideDir.exists(), "existing api directory should not be overridden") | ||
} | ||
} | ||
|
||
@Test | ||
fun validateDumpFromACustomDirectory() { | ||
val runner = test { | ||
buildGradleKts { | ||
resolve("/examples/gradle/base/withPlugin.gradle.kts") | ||
resolve("/examples/gradle/configuration/outputDirectory/different.gradle.kts") | ||
} | ||
|
||
kotlin("AnotherBuildConfig.kt") { | ||
resolve("/examples/classes/AnotherBuildConfig.kt") | ||
} | ||
dir("custom") { | ||
file("${rootProjectDir.name}.api") { | ||
resolve("/examples/classes/AnotherBuildConfig.dump") | ||
} | ||
} | ||
|
||
runner { | ||
arguments.add(":apiCheck") | ||
} | ||
} | ||
|
||
runner.build().apply { | ||
assertTaskSuccess(":apiCheck") | ||
} | ||
} | ||
|
||
@Test | ||
fun dumpIntoSubdirectory() { | ||
val runner = test { | ||
buildGradleKts { | ||
resolve("/examples/gradle/base/withPlugin.gradle.kts") | ||
resolve("/examples/gradle/configuration/outputDirectory/subdirectory.gradle.kts") | ||
} | ||
|
||
kotlin("AnotherBuildConfig.kt") { | ||
resolve("/examples/classes/AnotherBuildConfig.kt") | ||
} | ||
|
||
runner { | ||
arguments.add(":apiDump") | ||
} | ||
} | ||
|
||
runner.build().apply { | ||
assertTaskSuccess(":apiDump") | ||
|
||
val dumpFile = rootProjectDir.resolve("validation") | ||
.resolve("api") | ||
.resolve("${rootProjectDir.name}.api") | ||
|
||
assertTrue(dumpFile.exists(), "api dump file ${dumpFile.path} should exist") | ||
|
||
val expected = readFileList("/examples/classes/AnotherBuildConfig.dump") | ||
Assertions.assertThat(dumpFile.readText()).isEqualToIgnoringNewLines(expected) | ||
} | ||
} | ||
|
||
@Test | ||
fun validateDumpFromASubdirectory() { | ||
val runner = test { | ||
buildGradleKts { | ||
resolve("/examples/gradle/base/withPlugin.gradle.kts") | ||
resolve("/examples/gradle/configuration/outputDirectory/subdirectory.gradle.kts") | ||
} | ||
|
||
kotlin("AnotherBuildConfig.kt") { | ||
resolve("/examples/classes/AnotherBuildConfig.kt") | ||
} | ||
dir("validation") { | ||
dir("api") { | ||
file("${rootProjectDir.name}.api") { | ||
resolve("/examples/classes/AnotherBuildConfig.dump") | ||
} | ||
} | ||
} | ||
|
||
runner { | ||
arguments.add(":apiCheck") | ||
} | ||
} | ||
|
||
runner.build().apply { | ||
assertTaskSuccess(":apiCheck") | ||
} | ||
} | ||
|
||
@Test | ||
fun dumpIntoParentDirectory() { | ||
val runner = test { | ||
buildGradleKts { | ||
resolve("/examples/gradle/base/withPlugin.gradle.kts") | ||
resolve("/examples/gradle/configuration/outputDirectory/outer.gradle.kts") | ||
} | ||
|
||
kotlin("AnotherBuildConfig.kt") { | ||
resolve("/examples/classes/AnotherBuildConfig.kt") | ||
} | ||
|
||
runner { | ||
arguments.add(":apiDump") | ||
} | ||
} | ||
|
||
runner.buildAndFail().apply { | ||
Assertions.assertThat(output).contains("apiDumpDirectory (\"../api\") should be inside the project directory") | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...nctionalTest/resources/examples/gradle/configuration/outputDirectory/different.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Copyright 2016-2024 JetBrains s.r.o. | ||
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file. | ||
*/ | ||
|
||
configure<kotlinx.validation.ApiValidationExtension> { | ||
apiDumpDirectory = "custom" | ||
} |
8 changes: 8 additions & 0 deletions
8
src/functionalTest/resources/examples/gradle/configuration/outputDirectory/outer.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Copyright 2016-2024 JetBrains s.r.o. | ||
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file. | ||
*/ | ||
|
||
configure<kotlinx.validation.ApiValidationExtension> { | ||
apiDumpDirectory = "../api" | ||
} |
8 changes: 8 additions & 0 deletions
8
...ionalTest/resources/examples/gradle/configuration/outputDirectory/subdirectory.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Copyright 2016-2024 JetBrains s.r.o. | ||
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file. | ||
*/ | ||
|
||
configure<kotlinx.validation.ApiValidationExtension> { | ||
apiDumpDirectory = "validation/api" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters