service/dap: refactor the server into two layers (#2729)

* service/dap: refactor the server into two layers

* Add delay before setting debugger in remote tests

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
This commit is contained in:
polinasok 2021-10-04 09:13:17 -07:00 committed by GitHub
parent 6a282112cc
commit dc2f615c9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 219 additions and 162 deletions

File diff suppressed because it is too large Load Diff

@ -2808,7 +2808,7 @@ func TestHaltPreventsAutoResume(t *testing.T) {
// Send a halt request when trying to resume the program after being
// interrupted. This should allow the log message to be processed,
// but keep the process from continuing beyond the line.
resumeOnceAndCheckStop = func(s *Server, command string, allowNextStateChange chan struct{}) (*api.DebuggerState, error) {
resumeOnceAndCheckStop = func(s *Session, command string, allowNextStateChange chan struct{}) (*api.DebuggerState, error) {
// This should trigger after the log message is sent, but before
// execution is resumed.
if command == api.DirectionCongruentContinue {
@ -5579,9 +5579,15 @@ func launchDebuggerWithTargetHalted(t *testing.T, fixture string) *debugger.Debu
func runTestWithDebugger(t *testing.T, dbg *debugger.Debugger, test func(c *daptest.Client)) {
serverStopped := make(chan struct{})
server, _ := startDapServer(t, serverStopped)
// TODO(polina): update once the server interface is refactored to take debugger as arg
server.debugger = dbg
client := daptest.NewClient(server.listener.Addr().String())
time.Sleep(100 * time.Millisecond) // Give time for connection to be set as dap.Session
// TODO(polina): update once the server interface is refactored to take debugger as arg
server.sessionMu.Lock()
if server.session == nil {
t.Fatal("dap session is not ready")
}
server.session.debugger = dbg
server.sessionMu.Unlock()
defer client.Close()
client.InitializeRequest()
client.ExpectInitializeResponseAndCapabilities(t)