JPS, tests: Support multimodule mpp tests without steps
This commit is contained in:
+25
-15
@@ -67,8 +67,7 @@ import kotlin.reflect.jvm.javaField
|
|||||||
|
|
||||||
abstract class AbstractIncrementalJpsTest(
|
abstract class AbstractIncrementalJpsTest(
|
||||||
private val allowNoFilesWithSuffixInTestData: Boolean = false,
|
private val allowNoFilesWithSuffixInTestData: Boolean = false,
|
||||||
private val checkDumpsCaseInsensitively: Boolean = false,
|
private val checkDumpsCaseInsensitively: Boolean = false
|
||||||
private val allowNoBuildLogFileInTestData: Boolean = false
|
|
||||||
) : BaseKotlinJpsBuildTestCase() {
|
) : BaseKotlinJpsBuildTestCase() {
|
||||||
companion object {
|
companion object {
|
||||||
private val COMPILATION_FAILED = "COMPILATION FAILED"
|
private val COMPILATION_FAILED = "COMPILATION FAILED"
|
||||||
@@ -305,6 +304,7 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
protected open fun doTest(testDataPath: String) {
|
protected open fun doTest(testDataPath: String) {
|
||||||
testDataDir = File(testDataPath)
|
testDataDir = File(testDataPath)
|
||||||
workDir = FileUtilRt.createTempDirectory(TEMP_DIRECTORY_TO_USE, "jps-build", null)
|
workDir = FileUtilRt.createTempDirectory(TEMP_DIRECTORY_TO_USE, "jps-build", null)
|
||||||
|
val buildLogFile = buildLogFinder.findBuildLog(testDataDir)
|
||||||
Disposer.register(testRootDisposable, Disposable { FileUtilRt.delete(workDir) })
|
Disposer.register(testRootDisposable, Disposable { FileUtilRt.delete(workDir) })
|
||||||
|
|
||||||
val modulesTxt = configureModules()
|
val modulesTxt = configureModules()
|
||||||
@@ -312,19 +312,19 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
|
|
||||||
initialMake()
|
initialMake()
|
||||||
|
|
||||||
val otherMakeResults = performModificationsAndMake(modulesTxt?.modules?.map { it.name })
|
val otherMakeResults = performModificationsAndMake(
|
||||||
val buildLogFile = buildLogFinder.findBuildLog(testDataDir)
|
modulesTxt?.modules?.map { it.name },
|
||||||
val logs = createBuildLog(otherMakeResults)
|
hasBuildLog = buildLogFile != null
|
||||||
|
)
|
||||||
|
|
||||||
if (buildLogFile != null && buildLogFile.exists()) {
|
buildLogFile?.let {
|
||||||
|
val logs = createBuildLog(otherMakeResults)
|
||||||
UsefulTestCase.assertSameLinesWithFile(buildLogFile.absolutePath, logs)
|
UsefulTestCase.assertSameLinesWithFile(buildLogFile.absolutePath, logs)
|
||||||
} else if (!allowNoBuildLogFileInTestData) {
|
|
||||||
throw IllegalStateException("No build log file in $testDataDir")
|
|
||||||
}
|
|
||||||
|
|
||||||
val lastMakeResult = otherMakeResults.last()
|
val lastMakeResult = otherMakeResults.last()
|
||||||
rebuildAndCheckOutput(lastMakeResult)
|
rebuildAndCheckOutput(lastMakeResult)
|
||||||
clearCachesRebuildAndCheckOutput(lastMakeResult)
|
clearCachesRebuildAndCheckOutput(lastMakeResult)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createMappingsDump(
|
private fun createMappingsDump(
|
||||||
@@ -411,15 +411,25 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
open val testDataSrc: File
|
open val testDataSrc: File
|
||||||
get() = testDataDir
|
get() = testDataDir
|
||||||
|
|
||||||
private fun performModificationsAndMake(moduleNames: Collection<String>?): List<MakeResult> {
|
private fun performModificationsAndMake(
|
||||||
|
moduleNames: Collection<String>?,
|
||||||
|
hasBuildLog: Boolean
|
||||||
|
): List<MakeResult> {
|
||||||
val results = arrayListOf<MakeResult>()
|
val results = arrayListOf<MakeResult>()
|
||||||
val modifications = getModificationsToPerform(
|
val modifications = getModificationsToPerform(
|
||||||
testDataSrc,
|
testDataSrc,
|
||||||
moduleNames,
|
moduleNames,
|
||||||
allowNoFilesWithSuffixInTestData,
|
allowNoFilesWithSuffixInTestData = allowNoFilesWithSuffixInTestData || !hasBuildLog,
|
||||||
TouchPolicy.TIMESTAMP
|
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 stepsTxt = File(testDataSrc, "_steps.txt")
|
||||||
val modificationNames = if (stepsTxt.exists()) stepsTxt.readLines() else null
|
val modificationNames = if (stepsTxt.exists()) stepsTxt.readLines() else null
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user