[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:
-7
@@ -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
|
||||
|
||||
+13
-4
@@ -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) }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user