From 6f683d5154866c8e514ba8e20c7ca5b0a5fcd4ad Mon Sep 17 00:00:00 2001 From: Sergey Rostov Date: Mon, 26 Nov 2018 09:06:30 +0300 Subject: [PATCH] JPS, tests: Support multimodule mpp tests without steps Original commit: ce4422e2ef1fbff6618f282ad91dcc3efcc33346 --- .../jps/build/AbstractIncrementalJpsTest.kt | 40 ++++++++++++------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt index d8179251762..18f5429ba96 100644 --- a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt @@ -67,8 +67,7 @@ import kotlin.reflect.jvm.javaField abstract class AbstractIncrementalJpsTest( private val allowNoFilesWithSuffixInTestData: Boolean = false, - private val checkDumpsCaseInsensitively: Boolean = false, - private val allowNoBuildLogFileInTestData: Boolean = false + private val checkDumpsCaseInsensitively: Boolean = false ) : BaseKotlinJpsBuildTestCase() { companion object { private val COMPILATION_FAILED = "COMPILATION FAILED" @@ -305,6 +304,7 @@ abstract class AbstractIncrementalJpsTest( protected open fun doTest(testDataPath: String) { testDataDir = File(testDataPath) workDir = FileUtilRt.createTempDirectory(TEMP_DIRECTORY_TO_USE, "jps-build", null) + val buildLogFile = buildLogFinder.findBuildLog(testDataDir) Disposer.register(testRootDisposable, Disposable { FileUtilRt.delete(workDir) }) val modulesTxt = configureModules() @@ -312,19 +312,19 @@ abstract class AbstractIncrementalJpsTest( initialMake() - val otherMakeResults = performModificationsAndMake(modulesTxt?.modules?.map { it.name }) - val buildLogFile = buildLogFinder.findBuildLog(testDataDir) - val logs = createBuildLog(otherMakeResults) + val otherMakeResults = performModificationsAndMake( + modulesTxt?.modules?.map { it.name }, + hasBuildLog = buildLogFile != null + ) - if (buildLogFile != null && buildLogFile.exists()) { + buildLogFile?.let { + val logs = createBuildLog(otherMakeResults) UsefulTestCase.assertSameLinesWithFile(buildLogFile.absolutePath, logs) - } else if (!allowNoBuildLogFileInTestData) { - throw IllegalStateException("No build log file in $testDataDir") - } - val lastMakeResult = otherMakeResults.last() - rebuildAndCheckOutput(lastMakeResult) - clearCachesRebuildAndCheckOutput(lastMakeResult) + val lastMakeResult = otherMakeResults.last() + rebuildAndCheckOutput(lastMakeResult) + clearCachesRebuildAndCheckOutput(lastMakeResult) + } } private fun createMappingsDump( @@ -411,15 +411,25 @@ abstract class AbstractIncrementalJpsTest( open val testDataSrc: File get() = testDataDir - private fun performModificationsAndMake(moduleNames: Collection?): List { + private fun performModificationsAndMake( + moduleNames: Collection?, + hasBuildLog: Boolean + ): List { val results = arrayListOf() val modifications = getModificationsToPerform( testDataSrc, moduleNames, - allowNoFilesWithSuffixInTestData, - TouchPolicy.TIMESTAMP + allowNoFilesWithSuffixInTestData = allowNoFilesWithSuffixInTestData || !hasBuildLog, + touchPolicy = TouchPolicy.TIMESTAMP ) + if (!hasBuildLog) { + check(modifications.size == 1 && modifications.single().isEmpty()) { + "Bad test data: build steps are provided, but there is no `build.log` file" + } + return results + } + val stepsTxt = File(testDataSrc, "_steps.txt") val modificationNames = if (stepsTxt.exists()) stepsTxt.readLines() else null