Skip to content

Commit

Permalink
Check Karma exit code with disabled failOnFailingTestSuite
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgonmic committed Oct 21, 2019
1 parent d902a5f commit 2cf79b7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ data class KarmaConfig(
val client: KarmaClient = KarmaClient(),
val browsers: MutableList<String> = mutableListOf(),
val customLaunchers: MutableMap<String, CustomLauncher> = mutableMapOf(),
val failOnFailingTestSuite: Boolean = false,
val reporters: MutableList<String> = mutableListOf(),
val preprocessors: MutableMap<String, MutableList<String>> = mutableMapOf(),
var coverageReporter: CoverageReporter? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,22 +325,15 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) : KotlinJsTestF
return object : JSServiceMessagesTestExecutionSpec(
forkOptions,
args,
false,
true,
clientSettings
) {
lateinit var progressLogger: ProgressLogger

var isLaunchFailed: Boolean = false

override fun wrapExecute(body: () -> Unit) {
project.operation("Running and building tests with karma and webpack") {
progressLogger = this
body()

if (isLaunchFailed) {
showSuppressedOutput()
throw IllegalStateException("Launch of some browsers was failed")
}
}
}

Expand All @@ -358,7 +351,7 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) : KotlinJsTestF
val value = text.trimEnd()
progressLogger.progress(value)

parseConsole(value)
super.printNonTestOutput(text)
}

override fun processStackTrace(stackTrace: String): String =
Expand Down Expand Up @@ -389,16 +382,6 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) : KotlinJsTestF

return rawSuiteNameOnly.replace(" ", ".") // sample.a.DeepPackageTest.Inner
}

private fun parseConsole(text: String) {
if (KARMA_PROBLEM.matches(text)) {
log.error(text)
isLaunchFailed = true
return
}

super.printNonTestOutput(text)
}
}
}
}
Expand All @@ -418,7 +401,5 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) : KotlinJsTestF
companion object {
const val CHROME_BIN = "CHROME_BIN"
const val CHROME_CANARY_BIN = "CHROME_CANARY_BIN"

val KARMA_PROBLEM = "(?m)^.*\\d{2} \\d{2} \\d{4,} \\d{2}:\\d{2}:\\d{2}.\\d{3}:(ERROR|WARN) \\[.*]: (.*)\$".toRegex()
}
}

0 comments on commit 2cf79b7

Please sign in to comment.