Implementing weak variant of testing for jps-based tests - test passes if gradle compiles at least all expected files, but if it compiles more - it is not a failure; using this variant for parametrized tests
KT-8487
This commit is contained in:
committed by
Alexey Tsvetkov
parent
ddf3ca276b
commit
4be395dcee
+15
-10
@@ -194,26 +194,31 @@ abstract class BaseGradleIT {
|
|||||||
fun CompiledProject.assertSameFiles(expected: Iterable<String>, actual: Iterable<String>, messagePrefix: String = ""): CompiledProject {
|
fun CompiledProject.assertSameFiles(expected: Iterable<String>, actual: Iterable<String>, messagePrefix: String = ""): CompiledProject {
|
||||||
val expectedSet = expected.toSortedSet()
|
val expectedSet = expected.toSortedSet()
|
||||||
val actualSet = actual.toSortedSet()
|
val actualSet = actual.toSortedSet()
|
||||||
assertTrue(actualSet == expectedSet, messagePrefix + "expected files: ${expectedSet.joinToString()}\n actual files: ${actualSet.joinToString()}")
|
assertTrue(actualSet == expectedSet, messagePrefix + "expected files: ${expectedSet.joinToString()}\n != actual files: ${actualSet.joinToString()}")
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun CompiledProject.assertContainFiles(expected: Iterable<String>, actual: Iterable<String>, messagePrefix: String = ""): CompiledProject {
|
fun CompiledProject.assertContainFiles(expected: Iterable<String>, actual: Iterable<String>, messagePrefix: String = ""): CompiledProject {
|
||||||
val expectedSet = expected.toSortedSet()
|
val actualSet = actual.toSortedSet()
|
||||||
assertTrue(expectedSet.containsAll(actual.toList()), messagePrefix + "expected files: ${expectedSet.joinToString()}\n actual files: ${actual.toSortedSet().joinToString()}")
|
assertTrue(actualSet.containsAll(expected.toList()), messagePrefix + "expected files: ${expected.toSortedSet().joinToString()}\n !in actual files: ${actualSet.joinToString()}")
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun CompiledProject.assertCompiledKotlinSources(sources: Iterable<String>): CompiledProject = assertSameFiles(sources, compiledKotlinSources.projectRelativePaths(this.project), "Compiled Kotlin files differ:\n ")
|
fun CompiledProject.assertCompiledKotlinSources(sources: Iterable<String>, weakTesting: Boolean = false): CompiledProject =
|
||||||
fun CompiledProject.assertCompiledKotlinSources(vararg sources: String): CompiledProject = assertCompiledKotlinSources(sources.asIterable())
|
if (weakTesting)
|
||||||
|
assertContainFiles(sources, compiledKotlinSources.projectRelativePaths(this.project), "Compiled Kotlin files differ:\n ")
|
||||||
|
else
|
||||||
|
assertSameFiles(sources, compiledKotlinSources.projectRelativePaths(this.project), "Compiled Kotlin files differ:\n ")
|
||||||
|
|
||||||
fun CompiledProject.assertCompiledKotlinSourcesContain(vararg sources: String): CompiledProject = assertContainFiles(sources.asIterable(), compiledKotlinSources.projectRelativePaths(this.project), "Compiled Kotlin files differ:\n ")
|
fun CompiledProject.assertCompiledKotlinSources(vararg sources: String, weakTesting: Boolean = false): CompiledProject = assertCompiledKotlinSources(sources.asIterable(), weakTesting)
|
||||||
|
|
||||||
fun CompiledProject.assertCompiledJavaSources(sources: Iterable<String>): CompiledProject = assertSameFiles(sources, compiledJavaSources.projectRelativePaths(this.project), "Compiled Java files differ:\n ")
|
fun CompiledProject.assertCompiledJavaSources(sources: Iterable<String>, weakTesting: Boolean = false): CompiledProject =
|
||||||
fun CompiledProject.assertCompiledJavaSources(vararg sources: String): CompiledProject = assertCompiledJavaSources(sources.asIterable())
|
if (weakTesting)
|
||||||
|
assertContainFiles(sources, compiledJavaSources.projectRelativePaths(this.project), "Compiled Java files differ:\n ")
|
||||||
fun CompiledProject.assertCompiledJavaSourcesContain(vararg sources: String): CompiledProject = assertContainFiles(sources.asIterable(), compiledJavaSources.projectRelativePaths(this.project), "Compiled Java files differ:\n ")
|
else
|
||||||
|
assertSameFiles(sources, compiledJavaSources.projectRelativePaths(this.project), "Compiled Java files differ:\n ")
|
||||||
|
|
||||||
|
fun CompiledProject.assertCompiledJavaSources(vararg sources: String, weakTesting: Boolean = false): CompiledProject = assertCompiledJavaSources(sources.asIterable(), weakTesting)
|
||||||
|
|
||||||
private fun Project.createBuildCommand(params: Array<out String>, options: BuildOptions): List<String> =
|
private fun Project.createBuildCommand(params: Array<out String>, options: BuildOptions): List<String> =
|
||||||
createGradleCommand(createGradleTailParameters(options, params))
|
createGradleCommand(createGradleTailParameters(options, params))
|
||||||
|
|||||||
+6
-6
@@ -134,7 +134,7 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun IncrementalTestProject.performAndAssertBuildStages(options: BuildOptions = defaultBuildOptions()) {
|
fun IncrementalTestProject.performAndAssertBuildStages(options: BuildOptions = defaultBuildOptions(), weakTesting: Boolean = false) {
|
||||||
|
|
||||||
val checkKnown = testIsKnownJpsTestProject(resourcesRoot)
|
val checkKnown = testIsKnownJpsTestProject(resourcesRoot)
|
||||||
Assume.assumeTrue(checkKnown.second ?: "", checkKnown.first)
|
Assume.assumeTrue(checkKnown.second ?: "", checkKnown.first)
|
||||||
@@ -157,22 +157,22 @@ dependencies {
|
|||||||
|
|
||||||
if (buildLog.size == 1) {
|
if (buildLog.size == 1) {
|
||||||
modify()
|
modify()
|
||||||
buildAndAssertStageResults(buildLog.first())
|
buildAndAssertStageResults(buildLog.first(), weakTesting = weakTesting)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
buildLog.forEachIndexed { stage, stageResults ->
|
buildLog.forEachIndexed { stage, stageResults ->
|
||||||
modify(stage + 1)
|
modify(stage + 1)
|
||||||
buildAndAssertStageResults(stageResults)
|
buildAndAssertStageResults(stageResults, weakTesting = weakTesting)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun IncrementalTestProject.buildAndAssertStageResults(expected: StageResults, options: BuildOptions = defaultBuildOptions()) {
|
fun IncrementalTestProject.buildAndAssertStageResults(expected: StageResults, options: BuildOptions = defaultBuildOptions(), weakTesting: Boolean = false) {
|
||||||
build("build", options = options) {
|
build("build", options = options) {
|
||||||
if (expected.compileSucceeded) {
|
if (expected.compileSucceeded) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertCompiledJavaSources(expected.compiledJavaFiles)
|
assertCompiledJavaSources(expected.compiledJavaFiles, weakTesting)
|
||||||
assertCompiledKotlinSources(expected.compiledKotlinFiles)
|
assertCompiledKotlinSources(expected.compiledKotlinFiles, weakTesting)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assertFailed()
|
assertFailed()
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ class KotlinGradlePluginJpsParametrizedIT : BaseIncrementalGradleIT() {
|
|||||||
@Test
|
@Test
|
||||||
fun testFromJps() {
|
fun testFromJps() {
|
||||||
try {
|
try {
|
||||||
JpsTestProject(jpsResourcesPath, relativePath).performAndAssertBuildStages()
|
JpsTestProject(jpsResourcesPath, relativePath).performAndAssertBuildStages(weakTesting = true)
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (defaultBuildOptions().withDaemon)
|
if (defaultBuildOptions().withDaemon)
|
||||||
|
|||||||
Reference in New Issue
Block a user