[Gradle, Test] makeSnapshotTo should fail when called in TC env

Developers (me) often forget to remove calls to this debugging
utility. Usually this changes is visible during Code Review but we
shouldn't rely on a sharp eye of a human. It is better to automatically
check it during remote run execution.
This commit is contained in:
Anton Lakotka
2024-02-19 09:30:54 +01:00
committed by Space Team
parent cd8843289b
commit bd84f93333
2 changed files with 4 additions and 1 deletions
@@ -446,7 +446,6 @@ class KotlinAndroidMppIT : KGPBaseTest() {
} }
""".trimIndent() """.trimIndent()
} }
makeSnapshotTo("/tmp/111")
build("publish") { build("publish") {
listOf("foobar", "foobaz").forEach { flavor -> listOf("foobar", "foobaz").forEach { flavor ->
listOf("-debug", "").forEach { buildType -> listOf("-debug", "").forEach { buildType ->
@@ -6,9 +6,11 @@
package org.jetbrains.kotlin.gradle.testbase package org.jetbrains.kotlin.gradle.testbase
import org.gradle.util.GradleVersion import org.gradle.util.GradleVersion
import org.jetbrains.kotlin.gradle.util.isTeamCityRun
import java.nio.file.Paths import java.nio.file.Paths
import java.nio.file.attribute.PosixFilePermission import java.nio.file.attribute.PosixFilePermission
import kotlin.io.path.* import kotlin.io.path.*
import kotlin.test.fail
/** /**
* Makes a snapshot of the current state of [TestProject] into [destinationPath]. * Makes a snapshot of the current state of [TestProject] into [destinationPath].
@@ -19,6 +21,8 @@ import kotlin.io.path.*
* To run task with the same build option as test - use `run.sh` (or `run.bat`) script. * To run task with the same build option as test - use `run.sh` (or `run.bat`) script.
*/ */
fun TestProject.makeSnapshotTo(destinationPath: String) { fun TestProject.makeSnapshotTo(destinationPath: String) {
if (isTeamCityRun) fail("Please remove `makeSnapshotTo()` call from test. It is utility for local debugging only!")
val dest = Paths val dest = Paths
.get(destinationPath) .get(destinationPath)
.resolve(projectName) .resolve(projectName)