Skip to content

Commit

Permalink
Log exception when internal error occurs during test execution (#884)
Browse files Browse the repository at this point in the history
  • Loading branch information
raniejade authored Apr 19, 2020
1 parent 005682a commit dc7f2ae
Showing 1 changed file with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,27 @@ import kotlin.system.exitProcess

class Spek2ConsoleLauncher {
fun run(args: LauncherArgs) {
val paths = args.paths.map {
PathBuilder.parse(it)
.build()
}
val context = JvmDiscoveryContextFactory.create(args.sourceDirs.toList())
val discoveryRequest = DiscoveryRequest(context, paths)
try {
val paths = args.paths.map {
PathBuilder.parse(it)
.build()
}
val context = JvmDiscoveryContextFactory.create(args.sourceDirs.toList())
val discoveryRequest = DiscoveryRequest(context, paths)

val runtime = SpekRuntime()
val runtime = SpekRuntime()

val discoveryResult = runtime.discover(discoveryRequest)
val executionRequest = ExecutionRequest(discoveryResult.roots, ServiceMessageAdapter())
runtime.execute(executionRequest)
// forces the jvm to shutdown even if there are non-daemon threads running.
// Ideally libraries should not leave non-daemon threads running after exit, unfortunately,
// this is quite common even with newer libraries.
exitProcess(0)
val discoveryResult = runtime.discover(discoveryRequest)
val executionRequest = ExecutionRequest(discoveryResult.roots, ServiceMessageAdapter())
runtime.execute(executionRequest)
// forces the jvm to shutdown even if there are non-daemon threads running.
// Ideally libraries should not leave non-daemon threads running after exit, unfortunately,
// this is quite common even with newer libraries.
exitProcess(0)
} catch (e: Throwable) {
println("An internal error has occurred.")
e.printStackTrace()
}
}
}

Expand Down

0 comments on commit dc7f2ae

Please sign in to comment.