[Gradle] KT-48818 Add tests for subprojects

Reuse already existing function to assert that
build log does not contain certain sub-strings
This commit is contained in:
Anton Lakotka
2021-10-21 23:26:32 +02:00
committed by Space
parent cb103dae75
commit 1057f24a69
2 changed files with 13 additions and 11 deletions
@@ -493,13 +493,6 @@ abstract class BaseGradleIT {
return this
}
fun CompiledProject.assertDoesNotContain(vararg notExpected: String, ignoreCase: Boolean = false): CompiledProject {
for (str in notExpected) {
assertFalse(output.contains(str.normalize(), ignoreCase), "Output should not contain '$str'")
}
return this
}
fun CompiledProject.assertContainsRegex(expected: Regex): CompiledProject {
assertTrue(expected.containsMatchIn(output), "Output should contain pattern '$expected'")
return this
@@ -30,6 +30,9 @@ internal class MppFlagsMigrationIT : BaseGradleIT() {
@Parameterized.Parameter(0)
lateinit var testCase: TestCase
@Parameterized.Parameter(1)
lateinit var testProjectName: String
companion object {
@OptIn(ExperimentalStdlibApi::class)
private val testCases = buildList {
@@ -99,13 +102,19 @@ internal class MppFlagsMigrationIT : BaseGradleIT() {
})
}
@Parameterized.Parameters(name = "{0}")
private val projectsToTest = listOf(
"new-mpp-published",
"hierarchical-mpp-project-dependency"
)
@Parameterized.Parameters(name = "{1}: {0}")
@JvmStatic
fun testCases() = testCases.map { arrayOf(it) }
fun testCases() = testCases
.flatMap { testCase -> projectsToTest.map { arrayOf(testCase, it) } }
}
val testProject by lazy {
Project("new-mpp-published").apply {
Project(testProjectName).apply {
setupWorkingDir()
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
gradleProperties().delete()
@@ -137,7 +146,7 @@ internal class MppFlagsMigrationIT : BaseGradleIT() {
assertFailed()
testCase.expectedPhraseInOutput?.let { assertContains(it, ignoreCase = true) }
testCase.notExpectedPhraseInOutput?.let { assertDoesNotContain(it, ignoreCase = true) }
testCase.notExpectedPhraseInOutput?.let { assertNotContains(it) }
}
}
}