Skip to content

Commit 68accc3

Browse files
committed
Log exception when internal error occurs during test execution (#884)
(cherry picked from commit dc7f2ae)
1 parent 890d022 commit 68accc3

File tree

1 file changed

+19
-14
lines changed
  • spek-ide-plugin-interop-jvm/src/main/kotlin/org/spekframework/ide

1 file changed

+19
-14
lines changed

spek-ide-plugin-interop-jvm/src/main/kotlin/org/spekframework/ide/console.kt

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,27 @@ import kotlin.system.exitProcess
1111

1212
class Spek2ConsoleLauncher {
1313
fun run(args: LauncherArgs) {
14-
val paths = args.paths.map {
15-
PathBuilder.parse(it)
16-
.build()
17-
}
18-
val context = JvmDiscoveryContextFactory.create(args.sourceDirs.toList())
19-
val discoveryRequest = DiscoveryRequest(context, paths)
14+
try {
15+
val paths = args.paths.map {
16+
PathBuilder.parse(it)
17+
.build()
18+
}
19+
val context = JvmDiscoveryContextFactory.create(args.sourceDirs.toList())
20+
val discoveryRequest = DiscoveryRequest(context, paths)
2021

21-
val runtime = SpekRuntime()
22+
val runtime = SpekRuntime()
2223

23-
val discoveryResult = runtime.discover(discoveryRequest)
24-
val executionRequest = ExecutionRequest(discoveryResult.roots, ServiceMessageAdapter())
25-
runtime.execute(executionRequest)
26-
// forces the jvm to shutdown even if there are non-daemon threads running.
27-
// Ideally libraries should not leave non-daemon threads running after exit, unfortunately,
28-
// this is quite common even with newer libraries.
29-
exitProcess(0)
24+
val discoveryResult = runtime.discover(discoveryRequest)
25+
val executionRequest = ExecutionRequest(discoveryResult.roots, ServiceMessageAdapter())
26+
runtime.execute(executionRequest)
27+
// forces the jvm to shutdown even if there are non-daemon threads running.
28+
// Ideally libraries should not leave non-daemon threads running after exit, unfortunately,
29+
// this is quite common even with newer libraries.
30+
exitProcess(0)
31+
} catch (e: Throwable) {
32+
println("An internal error has occurred.")
33+
e.printStackTrace()
34+
}
3035
}
3136
}
3237

0 commit comments

Comments
 (0)