Minor: fix warnings in AbstractIncrementalJpsTest.kt
* used new property access syntax
* splitBy -> split
* used string template instead of concatenation
Original commit: 6bed076228
This commit is contained in:
@@ -82,8 +82,8 @@ public abstract class AbstractIncrementalJpsTest(
|
||||
TestLoggerFactory.enableDebugLogging(myTestRootDisposable, "#org")
|
||||
|
||||
val console = ConsoleAppender()
|
||||
console.setLayout(PatternLayout("%d [%p|%c|%C{1}] %m%n"));
|
||||
console.setThreshold(Level.ALL)
|
||||
console.layout = PatternLayout("%d [%p|%c|%C{1}] %m%n");
|
||||
console.threshold = Level.ALL
|
||||
console.activateOptions()
|
||||
Logger.getRootLogger().addAppender(console)
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public abstract class AbstractIncrementalJpsTest(
|
||||
protected open fun checkLookups(@suppress("UNUSED_PARAMETER") lookupTracker: LookupTracker) {}
|
||||
|
||||
fun build(scope: CompileScopeTestBuilder = CompileScopeTestBuilder.make().all()): MakeResult {
|
||||
val workDirPath = FileUtil.toSystemIndependentName(workDir.getAbsolutePath())
|
||||
val workDirPath = FileUtil.toSystemIndependentName(workDir.absolutePath)
|
||||
val logger = MyLogger(workDirPath)
|
||||
val descriptor = createProjectDescriptor(BuildLoggingManager(logger))
|
||||
|
||||
@@ -126,11 +126,11 @@ public abstract class AbstractIncrementalJpsTest(
|
||||
|
||||
checkLookups(lookupTracker)
|
||||
|
||||
if (!buildResult.isSuccessful()) {
|
||||
if (!buildResult.isSuccessful) {
|
||||
val errorMessages =
|
||||
buildResult
|
||||
.getMessages(BuildMessage.Kind.ERROR)
|
||||
.map { it.getMessageText() }
|
||||
.map { it.messageText }
|
||||
.map { it.replace("^.+:\\d+:\\s+".toRegex(), "").trim() }
|
||||
.joinToString("\n")
|
||||
return MakeResult(logger.log + "$COMPILATION_FAILED\n" + errorMessages + "\n", true, null)
|
||||
@@ -170,7 +170,7 @@ public abstract class AbstractIncrementalJpsTest(
|
||||
assert(moduleNames != null) { "File name has module prefix, but multi-module environment is absent" }
|
||||
assert(module in moduleNames!!) { "Module not found for file with prefix: $fileName" }
|
||||
|
||||
return module + "/src"
|
||||
return "$module/src"
|
||||
}
|
||||
|
||||
assert(moduleNames == null) { "Test is multi-module, but file has no module prefix: $fileName" }
|
||||
@@ -240,7 +240,7 @@ public abstract class AbstractIncrementalJpsTest(
|
||||
}
|
||||
|
||||
private fun clearCachesRebuildAndCheckOutput(makeOverallResult: MakeResult) {
|
||||
FileUtil.delete(BuildDataPathsImpl(myDataStorageRoot).getDataStorageRoot()!!)
|
||||
FileUtil.delete(BuildDataPathsImpl(myDataStorageRoot).dataStorageRoot!!)
|
||||
|
||||
rebuildAndCheckOutput(makeOverallResult)
|
||||
}
|
||||
@@ -251,10 +251,10 @@ public abstract class AbstractIncrementalJpsTest(
|
||||
|
||||
val result = HashMap<String, List<String>>()
|
||||
for (line in dependenciesTxt.readLines()) {
|
||||
val split = line.splitBy("->")
|
||||
val split = line.split("->")
|
||||
val module = split[0]
|
||||
val dependencies = if (split.size() > 1) split[1] else ""
|
||||
val dependencyList = dependencies.splitBy(",").filterNot { it.isEmpty() }
|
||||
val dependencyList = dependencies.split(",").filterNot { it.isEmpty() }
|
||||
|
||||
result[module] = dependencyList
|
||||
}
|
||||
@@ -289,7 +289,7 @@ public abstract class AbstractIncrementalJpsTest(
|
||||
|
||||
private fun createKotlinIncrementalCacheDump(project: ProjectDescriptor): String {
|
||||
return StringBuilder {
|
||||
for (target in project.getBuildTargetIndex().getAllTargets().sortBy { it.getPresentableName() }) {
|
||||
for (target in project.buildTargetIndex.allTargets.sortBy { it.presentableName }) {
|
||||
append("<target $target>\n")
|
||||
append(project.dataManager.getKotlinCache(target).dump())
|
||||
append("</target $target>\n\n\n")
|
||||
@@ -304,15 +304,15 @@ public abstract class AbstractIncrementalJpsTest(
|
||||
result.println("Begin of SourceToOutputMap")
|
||||
result.pushIndent()
|
||||
|
||||
for (target in project.getBuildTargetIndex().getAllTargets()) {
|
||||
for (target in project.buildTargetIndex.allTargets) {
|
||||
result.println(target)
|
||||
result.pushIndent()
|
||||
|
||||
val mapping = project.dataManager.getSourceToOutputMap(target)
|
||||
mapping.getSources().forEach {
|
||||
mapping.sources.forEach {
|
||||
val outputs = mapping.getOutputs(it)!!.sort()
|
||||
if (outputs.isNotEmpty()) {
|
||||
result.println("source $it -> " + outputs)
|
||||
result.println("source $it -> $outputs")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ public abstract class AbstractIncrementalJpsTest(
|
||||
private fun createJavaMappingsDump(project: ProjectDescriptor): String {
|
||||
val byteArrayOutputStream = ByteArrayOutputStream()
|
||||
PrintStream(byteArrayOutputStream).use {
|
||||
project.dataManager.getMappings().toStream(it)
|
||||
project.dataManager.mappings.toStream(it)
|
||||
}
|
||||
return byteArrayOutputStream.toString()
|
||||
}
|
||||
@@ -353,8 +353,7 @@ public abstract class AbstractIncrementalJpsTest(
|
||||
// null means one module
|
||||
private fun configureModules(): Set<String>? {
|
||||
var moduleNames: Set<String>?
|
||||
JpsJavaExtensionService.getInstance().getOrCreateProjectExtension(myProject)
|
||||
.setOutputUrl(JpsPathUtil.pathToUrl(getAbsolutePath("out")))
|
||||
JpsJavaExtensionService.getInstance().getOrCreateProjectExtension(myProject).outputUrl = JpsPathUtil.pathToUrl(getAbsolutePath("out"))
|
||||
|
||||
val jdk = addJdk("my jdk")
|
||||
val moduleDependencies = readModuleDependencies()
|
||||
@@ -370,7 +369,7 @@ public abstract class AbstractIncrementalJpsTest(
|
||||
}
|
||||
else {
|
||||
val nameToModule = moduleDependencies.keySet()
|
||||
.keysToMap { addModule(it, arrayOf(getAbsolutePath(it + "/src")), null, null, jdk)!! }
|
||||
.keysToMap { addModule(it, arrayOf(getAbsolutePath("$it/src")), null, null, jdk)!! }
|
||||
|
||||
for ((moduleName, dependencies) in moduleDependencies) {
|
||||
val module = nameToModule[moduleName]!!
|
||||
@@ -380,9 +379,9 @@ public abstract class AbstractIncrementalJpsTest(
|
||||
}
|
||||
|
||||
for (module in nameToModule.values()) {
|
||||
val moduleName = module.getName()
|
||||
val moduleName = module.name
|
||||
|
||||
val srcDir = File(workDir, moduleName + "/src")
|
||||
val srcDir = File(workDir, "$moduleName/src")
|
||||
FileUtil.copyDir(testDataDir, srcDir,
|
||||
{ it.getName().startsWith(moduleName + "_") && (it.getName().endsWith(".kt") || it.getName().endsWith(".java")) })
|
||||
|
||||
@@ -408,14 +407,14 @@ public abstract class AbstractIncrementalJpsTest(
|
||||
override fun isEnabled(): Boolean = true
|
||||
|
||||
override fun logLine(message: String?) {
|
||||
logBuf.append(JetTestUtils.replaceHashWithStar(message!!.removePrefix(rootPath + "/"))).append('\n')
|
||||
logBuf.append(JetTestUtils.replaceHashWithStar(message!!.removePrefix("$rootPath/"))).append('\n')
|
||||
}
|
||||
}
|
||||
|
||||
private abstract class Modification(val path: String) {
|
||||
abstract fun perform(workDir: File)
|
||||
|
||||
override fun toString(): String = "${javaClass.getSimpleName()} $path"
|
||||
override fun toString(): String = "${javaClass.simpleName} $path"
|
||||
}
|
||||
|
||||
private class ModifyContent(path: String, val dataFile: File) : Modification(path) {
|
||||
|
||||
Reference in New Issue
Block a user