File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed
adapter/src/test/kotlin/org/javacs/ktda Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -5,18 +5,21 @@ import java.nio.file.Paths
5
5
import org.eclipse.lsp4j.debug.DisconnectArguments
6
6
import org.javacs.ktda.adapter.KotlinDebugAdapter
7
7
import org.javacs.ktda.jdi.launch.JDILauncher
8
- import org.junit.AfterClass
8
+ import org.junit.After
9
9
10
- abstract class DebugAdapterTestFixture (relativeWorkspaceRoot : String ) {
10
+ abstract class DebugAdapterTestFixture (relativeWorkspaceRoot : String , mainClass : String ) {
11
11
val absoluteWorkspaceRoot: Path = Paths .get(DebugAdapterTestFixture ::class .java.getResource(" /" ).toURI()).resolve(relativeWorkspaceRoot)
12
12
val debugAdapter: KotlinDebugAdapter = JDILauncher ()
13
13
.let (::KotlinDebugAdapter )
14
- .also { it.launch(mapOf (
14
+
15
+ fun launch () {
16
+ debugAdapter.launch(mapOf (
15
17
" projectRoot" to absoluteWorkspaceRoot.toString(),
16
18
" mainClass" to " sample.workspace.AppKt"
17
- )) }
19
+ ))
20
+ }
18
21
19
- @AfterClass private fun closeDebugAdapter () {
22
+ @After fun closeDebugAdapter () {
20
23
debugAdapter.disconnect(DisconnectArguments ()).join()
21
24
}
22
25
}
Original file line number Diff line number Diff line change @@ -13,13 +13,16 @@ import org.junit.Assert.assertThat
13
13
import org.junit.Test
14
14
import org.hamcrest.Matchers.contains
15
15
import org.hamcrest.Matchers.equalTo
16
+ import java.util.concurrent.Semaphore
16
17
17
18
/* *
18
19
* Tests a very basic debugging scenario
19
20
* using a sample application.
20
21
*/
21
- class SampleWorkspaceTest : DebugAdapterTestFixture (" sample-workspace" ) {
22
- @Test private fun testBreakpointsAndVariables () {
22
+ class SampleWorkspaceTest : DebugAdapterTestFixture (" sample-workspace" , " sample.workspace.AppKt" ) {
23
+ @Test fun testBreakpointsAndVariables () {
24
+ val semaphore = Semaphore (0 )
25
+
23
26
debugAdapter.connect(object : IDebugProtocolClient {
24
27
override fun stopped (args : StoppedEventArguments ) {
25
28
assertThat(args.reason, equalTo(" breakpoint" ))
@@ -41,6 +44,7 @@ class SampleWorkspaceTest : DebugAdapterTestFixture("sample-workspace") {
41
44
Pair (" member" , " \" test\" " ),
42
45
Pair (" local" , " 123" )
43
46
))
47
+ semaphore.release()
44
48
}
45
49
})
46
50
debugAdapter.setBreakpoints(SetBreakpointsArguments ().apply {
@@ -58,5 +62,7 @@ class SampleWorkspaceTest : DebugAdapterTestFixture("sample-workspace") {
58
62
line = 8
59
63
})
60
64
})
65
+ launch()
66
+ semaphore.acquire() // Wait for the end
61
67
}
62
68
}
You can’t perform that action at this time.
0 commit comments