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 {
|
||||
val expectedSet = expected.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
|
||||
}
|
||||
|
||||
fun CompiledProject.assertContainFiles(expected: Iterable<String>, actual: Iterable<String>, messagePrefix: String = ""): CompiledProject {
|
||||
val expectedSet = expected.toSortedSet()
|
||||
assertTrue(expectedSet.containsAll(actual.toList()), messagePrefix + "expected files: ${expectedSet.joinToString()}\n actual files: ${actual.toSortedSet().joinToString()}")
|
||||
val actualSet = actual.toSortedSet()
|
||||
assertTrue(actualSet.containsAll(expected.toList()), messagePrefix + "expected files: ${expected.toSortedSet().joinToString()}\n !in actual files: ${actualSet.joinToString()}")
|
||||
return this
|
||||
}
|
||||
|
||||
fun CompiledProject.assertCompiledKotlinSources(sources: Iterable<String>): CompiledProject = assertSameFiles(sources, compiledKotlinSources.projectRelativePaths(this.project), "Compiled Kotlin files differ:\n ")
|
||||
fun CompiledProject.assertCompiledKotlinSources(vararg sources: String): CompiledProject = assertCompiledKotlinSources(sources.asIterable())
|
||||
fun CompiledProject.assertCompiledKotlinSources(sources: Iterable<String>, weakTesting: Boolean = false): CompiledProject =
|
||||
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(vararg sources: String): CompiledProject = assertCompiledJavaSources(sources.asIterable())
|
||||
|
||||
fun CompiledProject.assertCompiledJavaSourcesContain(vararg sources: String): CompiledProject = assertContainFiles(sources.asIterable(), compiledJavaSources.projectRelativePaths(this.project), "Compiled Java files differ:\n ")
|
||||
fun CompiledProject.assertCompiledJavaSources(sources: Iterable<String>, weakTesting: Boolean = false): CompiledProject =
|
||||
if (weakTesting)
|
||||
assertContainFiles(sources, 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> =
|
||||
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)
|
||||
Assume.assumeTrue(checkKnown.second ?: "", checkKnown.first)
|
||||
@@ -157,22 +157,22 @@ dependencies {
|
||||
|
||||
if (buildLog.size == 1) {
|
||||
modify()
|
||||
buildAndAssertStageResults(buildLog.first())
|
||||
buildAndAssertStageResults(buildLog.first(), weakTesting = weakTesting)
|
||||
}
|
||||
else {
|
||||
buildLog.forEachIndexed { stage, stageResults ->
|
||||
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) {
|
||||
if (expected.compileSucceeded) {
|
||||
assertSuccessful()
|
||||
assertCompiledJavaSources(expected.compiledJavaFiles)
|
||||
assertCompiledKotlinSources(expected.compiledKotlinFiles)
|
||||
assertCompiledJavaSources(expected.compiledJavaFiles, weakTesting)
|
||||
assertCompiledKotlinSources(expected.compiledKotlinFiles, weakTesting)
|
||||
}
|
||||
else {
|
||||
assertFailed()
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ class KotlinGradlePluginJpsParametrizedIT : BaseIncrementalGradleIT() {
|
||||
@Test
|
||||
fun testFromJps() {
|
||||
try {
|
||||
JpsTestProject(jpsResourcesPath, relativePath).performAndAssertBuildStages()
|
||||
JpsTestProject(jpsResourcesPath, relativePath).performAndAssertBuildStages(weakTesting = true)
|
||||
}
|
||||
finally {
|
||||
if (defaultBuildOptions().withDaemon)
|
||||
|
||||
Reference in New Issue
Block a user