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 3, 2019
1 parent 58e9b75 commit fa90d5c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ data class KarmaConfig(
val client: KarmaClient = KarmaClient(),
val browsers: MutableList<String> = mutableListOf(),
val customLaunchers: MutableMap<String, CustomLauncher> = mutableMapOf(),
// https://github.com/karma-runner/karma/pull/3116
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 @@ -318,22 +318,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 @@ -351,7 +344,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 @@ -382,16 +375,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 @@ -411,7 +394,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 fa90d5c

Please sign in to comment.