mirror of
https://github.com/apple/pkl.git
synced 2026-05-25 16:19:20 +02:00
Introduce "minimal" test reporter (#1563)
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.pkl.cli
|
||||
|
||||
import java.io.StringWriter
|
||||
import java.io.Writer
|
||||
import org.pkl.commons.cli.*
|
||||
import org.pkl.core.Closeables
|
||||
@@ -22,8 +23,9 @@ import org.pkl.core.EvaluatorBuilder
|
||||
import org.pkl.core.ModuleSource.uri
|
||||
import org.pkl.core.PklException
|
||||
import org.pkl.core.TestResults
|
||||
import org.pkl.core.stdlib.test.report.JUnitReport
|
||||
import org.pkl.core.stdlib.test.report.SimpleReport
|
||||
import org.pkl.core.stdlib.test.report.JUnitReporter
|
||||
import org.pkl.core.stdlib.test.report.MinimalReporter
|
||||
import org.pkl.core.stdlib.test.report.SpecReporter
|
||||
import org.pkl.core.util.ErrorMessages
|
||||
|
||||
class CliTestRunner
|
||||
@@ -64,13 +66,15 @@ constructor(
|
||||
var failed = false
|
||||
var isExampleWrittenFailure = true
|
||||
val moduleNames = mutableSetOf<String>()
|
||||
val reporter = SimpleReport(useColor)
|
||||
val reporter =
|
||||
when (testOptions.reporter) {
|
||||
TestReporter.SPEC -> SpecReporter(useColor)
|
||||
TestReporter.MINIMAL -> MinimalReporter(useColor)
|
||||
}
|
||||
val allTestResults = mutableListOf<TestResults>()
|
||||
|
||||
val junitDir = testOptions.junitDir
|
||||
if (junitDir != null) {
|
||||
junitDir.toFile().mkdirs()
|
||||
}
|
||||
junitDir?.toFile()?.mkdirs()
|
||||
|
||||
for ((idx, moduleUri) in sources.withIndex()) {
|
||||
try {
|
||||
@@ -80,8 +84,11 @@ constructor(
|
||||
failed = results.failed()
|
||||
isExampleWrittenFailure = results.isExampleWrittenFailure.and(isExampleWrittenFailure)
|
||||
}
|
||||
reporter.report(results, consoleWriter)
|
||||
if (sources.size > 1 && idx != sources.size - 1) {
|
||||
val tmpWriter = StringWriter()
|
||||
reporter.report(results, tmpWriter)
|
||||
val report = tmpWriter.toString()
|
||||
consoleWriter.write(report)
|
||||
if (report.isNotEmpty() && sources.size > 1 && idx != sources.size - 1) {
|
||||
consoleWriter.append('\n')
|
||||
}
|
||||
consoleWriter.flush()
|
||||
@@ -101,7 +108,7 @@ constructor(
|
||||
moduleNames += moduleName
|
||||
|
||||
if (!testOptions.junitAggregateReports) {
|
||||
JUnitReport().reportToPath(results, junitDir.resolve(moduleName))
|
||||
JUnitReporter().reportToPath(results, junitDir.resolve(moduleName))
|
||||
}
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
@@ -119,7 +126,7 @@ constructor(
|
||||
}
|
||||
if (testOptions.junitAggregateReports && junitDir != null) {
|
||||
val fileName = "${testOptions.junitAggregateSuiteName}.xml"
|
||||
JUnitReport(testOptions.junitAggregateSuiteName)
|
||||
JUnitReporter(testOptions.junitAggregateSuiteName)
|
||||
.summarizeToPath(allTestResults, junitDir.resolve(fileName))
|
||||
}
|
||||
consoleWriter.append('\n')
|
||||
|
||||
Reference in New Issue
Block a user