1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

Handle zero projects more gracefully.

This commit is contained in:
Cedric Beust 2016-08-12 00:24:22 -08:00
parent 2498284043
commit c2c4a156de
2 changed files with 23 additions and 17 deletions

View file

@ -59,7 +59,6 @@ class BuildListeners : IBuildListener, IBuildReportContributor {
fun formatMillisLeft(millis: Long, length: Int) = formatMillis(millis, "%1\$-$length.2f") fun formatMillisLeft(millis: Long, length: Int) = formatMillis(millis, "%1\$-$length.2f")
fun millisToSeconds(millis: Long) = (millis.toDouble() / 1000).toInt() fun millisToSeconds(millis: Long) = (millis.toDouble() / 1000).toInt()
val buildTime = millisToSeconds(System.currentTimeMillis() - buildStartTime!!)
val profiling = args.profiling val profiling = args.profiling
if (profiling) { if (profiling) {
@ -94,6 +93,11 @@ class BuildListeners : IBuildListener, IBuildReportContributor {
// } // }
} }
val buildTime =
if (buildStartTime != null)
millisToSeconds(System.currentTimeMillis() - buildStartTime!!)
else
0
// BUILD SUCCESSFUL / FAILED message // BUILD SUCCESSFUL / FAILED message
val message = val message =
if (hasFailures) { if (hasFailures) {

View file

@ -339,26 +339,28 @@ class DynamicGraphExecutor<T>(val graph : DynamicGraph<T>, val factory: IThreadW
} }
fun displayRegularLog(table: AsciiTable.Builder) : AsciiTable.Builder { fun displayRegularLog(table: AsciiTable.Builder) : AsciiTable.Builder {
val start = historyLog[0].timestamp if (historyLog.any()) {
val projectStart = ConcurrentHashMap<String, Long>() val start = historyLog[0].timestamp
historyLog.forEach { line -> val projectStart = ConcurrentHashMap<String, Long>()
val row = arrayListOf<String>() historyLog.forEach { line ->
row.add(toSeconds(line.timestamp - start)) val row = arrayListOf<String>()
threadIds.keys.forEach { row.add(toSeconds(line.timestamp - start))
if (line.threadId == it) { threadIds.keys.forEach {
var duration = "" if (line.threadId == it) {
if (line.start) { var duration = ""
projectStart[line.name] = line.timestamp if (line.start) {
projectStart[line.name] = line.timestamp
} else {
duration = " (" + ((line.timestamp - projectStart[line.name]!!) / 1000)
.toInt().toString() + ")"
}
row.add((line.name + duration))
} else { } else {
duration = " (" + ((line.timestamp - projectStart[line.name]!!) / 1000) row.add("")
.toInt().toString() + ")"
} }
row.add((line.name + duration))
} else {
row.add("")
} }
table.addRow(row)
} }
table.addRow(row)
} }
return table return table
} }