Skip to content

Commit

Permalink
Bunch of fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
slinkydeveloper committed Jul 31, 2024
1 parent 670b47a commit 9f534aa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/main/kotlin/dev/restate/sdktesting/junit/TestSuite.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder
import org.junit.platform.launcher.core.LauncherFactory
import org.junit.platform.launcher.listeners.SummaryGeneratingListener
import org.junit.platform.launcher.listeners.TestExecutionSummary
import org.junit.platform.reporting.open.xml.OpenTestReportGeneratingListener
import org.junit.platform.reporting.legacy.xml.LegacyXmlReportGeneratingListener

class TestSuite(
val name: String,
Expand Down Expand Up @@ -66,9 +66,6 @@ class TestSuite(
.selectors(DiscoverySelectors.selectPackage("dev.restate.sdktesting.tests"))
.filters(TagFilter.includeTags(junitIncludeTags))
.filters(*filters.toTypedArray())
// OpenXML reporting
.configurationParameter("junit.platform.reporting.open.xml.enabled", "true")
.configurationParameter("junit.platform.reporting.output.dir", reportDir.toString())
// Redirect STDOUT/STDERR
.configurationParameter(LauncherConstants.CAPTURE_STDOUT_PROPERTY_NAME, "true")
.configurationParameter(LauncherConstants.CAPTURE_STDERR_PROPERTY_NAME, "true")
Expand All @@ -78,13 +75,16 @@ class TestSuite(
.build()

// Configure listeners
val errWriter = PrintWriter(System.err)
// TODO replace this with our own listener
val summaryListener = SummaryGeneratingListener()
val xmlReportListener = OpenTestReportGeneratingListener()
// TODO replace this with our own xml writer
val xmlReportListener = LegacyXmlReportGeneratingListener(reportDir, errWriter)
val redirectStdoutAndStderrListener =
RedirectStdoutAndStderrListener(
reportDir.resolve("testrunner.stdout"),
reportDir.resolve("testrunner.stderr"),
PrintWriter(System.err))
errWriter)
val injectLoggingContextListener =
object : TestExecutionListener {
val TEST_NAME = "test"
Expand Down
15 changes: 12 additions & 3 deletions src/main/kotlin/dev/restate/sdktesting/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import kotlinx.serialization.Serializable
import org.junit.platform.engine.Filter
import org.junit.platform.engine.discovery.ClassNameFilter
import org.junit.platform.engine.support.descriptor.ClassSource
import org.junit.platform.engine.support.descriptor.MethodSource

data class CommonConfig(var verbose: Boolean = false)

Expand Down Expand Up @@ -136,6 +137,7 @@ Run test suite, executing the service as container.

val aggregateResults = AggregateResults()
val failedTests = mutableMapOf<String, List<String>>()
var newFailures = false
for (testSuite in testSuites) {
val exclusions = loadedExclusions.exclusions[testSuite.name] ?: emptyList()
val exclusionsFilters = exclusions.map { ClassNameFilter.excludeClassNamePatterns(it) }
Expand All @@ -160,8 +162,15 @@ Run test suite, executing the service as container.
failedTests[testSuite.name] =
report.failures
.mapNotNull { it.testIdentifier.source.getOrNull() }
.mapNotNull { if (it is ClassSource) it else null }
.map { it.className!! } + exclusions
.mapNotNull {
when (it) {
is ClassSource -> it.className!!
is MethodSource -> it.className!!
else -> null
}
}
.distinct() + exclusions
newFailures = true
}
}

Expand All @@ -180,7 +189,7 @@ Run test suite, executing the service as container.
"""
.trimIndent())

if (failedTests.isNotEmpty()) {
if (newFailures) {
// Exit
exitProcess(1)
}
Expand Down

0 comments on commit 9f534aa

Please sign in to comment.