@@ -11,22 +11,27 @@ import kotlin.system.exitProcess
11
11
12
12
class Spek2ConsoleLauncher {
13
13
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)
20
21
21
- val runtime = SpekRuntime ()
22
+ val runtime = SpekRuntime ()
22
23
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
+ }
30
35
}
31
36
}
32
37
0 commit comments