Skip to content

udb: add DAP test client - #582

Open
JosephAbdo wants to merge 9 commits into
uniconproject:masterfrom
JosephAbdo:dap_test_client
Open

JosephAbdo wants to merge 9 commits into
uniconproject:masterfrom
JosephAbdo:dap_test_client

Conversation

@JosephAbdo

Copy link
Copy Markdown
Contributor

Add a DAP test client, includes request coverage for:

  • initialize
  • launch
  • configurationDone
  • threads
  • continue
  • disconnect

@greptile-apps

greptile-apps Bot commented Apr 6, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR introduces a DAP test client (DAP_TestClient) that exercises the udb adapter end-to-end over a real TCP connection, covering initialize → launch → setBreakpoints → configurationDone → inspect → step → disconnect. The test client is wired into the existing tests/udb/ suite via a custom adapter make target and a golden-file comparison against stand/adapter.std.

The remaining findings are all P2: setDataBreakpoints is run before dataBreakpointInfo in run_tests() (reversing the intended DAP protocol order), the test client source exists in two near-identical copies (uni/udb/test_adapter.icn and tests/udb/adapter.icn) that will need to be kept in sync manually, and retry-loop diagnostic messages are silently suppressed in the compiled copy.

Confidence Score: 5/5

Safe to merge; all remaining findings are P2 style/maintainability issues that do not block correctness.

The previously flagged P0/P1 issues (fail_test propagation, runInTerminal slice off-by-one, disconnectPending, Makefile missing rules) are resolved in the current code. Only P2 suggestions remain: reversed test ordering for dataBreakpoint tests, duplicate source files, and silent retries.

tests/udb/adapter.icn and uni/udb/test_adapter.icn — two copies of the same client that must be kept in sync.

Important Files Changed

Filename Overview
uni/udb/test_adapter.icn New DAP test client (source copy); runInTerminal path check correctly uses [1:5]; explicit fail after every fail_test call so failure propagates correctly; uses ./udb path (differs from tests/ copy)
tests/udb/adapter.icn Compiled/run copy of the test client; setDataBreakpoints runs before dataBreakpointInfo in run_tests() (reversed DAP protocol order); retry loop is silent; near-duplicate of uni/udb/test_adapter.icn with path differences
tests/udb/Makefile Adds adapter test target with inline compile-and-run rule; CLEAN_EXTRA lists test_adapter and data/test_target but these are not consumed by Makefile.test's clean rule (pre-existing pattern)
uni/udb/adapter.icn disconnect case calls disconnect() directly (correct); disconnectPending field declared and reset in startup() but is never set to 1 — dead field, not a regression
uni/udb/breakpoint.icn Adds base-name fallback matching in checkBreakpoint() so a relative-path breakpoint can match an absolute path in the debug session; logic appears correct

Sequence Diagram

sequenceDiagram
    participant TC as DAP_TestClient
    participant UA as udb Adapter
    participant UDB as udb --dapproxy

    TC->>UA: initialize
    UA-->>TC: response (capabilities)
    UA-->>TC: event: initialized

    TC->>UA: launch {program}
    UA-->>TC: request: runInTerminal {udb --dapproxy PORT}
    TC->>UDB: system(udb --dapproxy PORT &)
    TC-->>UA: response: runInTerminal {shellProcessId}
    UA-->>TC: response: launch (success)

    TC->>UA: setBreakpoints
    UA-->>TC: response (verified breakpoints)

    TC->>UA: setDataBreakpoints
    UA-->>TC: response (watchpoints)

    TC->>UA: dataBreakpointInfo
    UA-->>TC: response {dataId, accessTypes}

    TC->>UA: configurationDone
    UA-->>TC: response (ack)
    UA-->>TC: event: stopped (breakpoint hit)

    TC->>UA: threads / stackTrace / scopes / variables / setVariable / evaluate
    UA-->>TC: responses

    TC->>UA: continue
    UA-->>TC: response (ack)

    TC->>UA: next / stepIn / stepOut
    UA-->>TC: responses (ack)

    TC->>UA: disconnect
    UA-->>TC: response (ack)
    UA->>UA: disconnect() then exit()
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: tests/udb/adapter.icn
Line: 581-586

Comment:
**`setDataBreakpoints` runs before `dataBreakpointInfo` in `run_tests()`**

The DAP protocol intends `dataBreakpointInfo` to be called first to obtain the opaque `dataId` that is then passed to `setDataBreakpoints`. Here the order is reversed: `test_setDataBreakpoints` runs first (line 582) and hardcodes `dataId := "i"`, then `test_dataBreakpointInfo` (line 583) fires afterward. This works incidentally because the adapter's `watchpoint_info` simply reflects the `name` back as `dataId`, but it means the test doesn't exercise the real client workflow and would silently succeed even if the adapter stopped returning a `dataId` altogether.

Consider swapping the two test calls so the golden-file ordering also matches the intended protocol sequence.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: tests/udb/adapter.icn
Line: 1-7

Comment:
**Duplicate test client source with diverging paths**

`tests/udb/adapter.icn` and `uni/udb/test_adapter.icn` are almost identical; they differ only in the path used to locate `udb`/`unicon` (`../../bin/` vs `./`) and in whether `main()` compiles the test target at runtime. Any future logic change to one file must be manually replicated in the other, which is error-prone. Consider having `tests/udb/Makefile` compile `uni/udb/test_adapter.icn` directly (with a path override), or factoring the shared logic into a linked file, to avoid drift between the two copies.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: tests/udb/adapter.icn
Line: 45-55

Comment:
**Silent retry loop in compiled copy**

`uni/udb/test_adapter.icn` emits `"Retrying adapter startup with another port..."` on each retry attempt — useful for diagnosing flaky CI runs. The `tests/udb/adapter.icn` version (which is the one actually compiled and run) omits that write, so retry attempts are completely silent. Since stdout is compared against a golden file, suppressing the message from stdout makes sense, but consider redirecting it to stderr so failures during retry are still diagnosable.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (9): Last reviewed commit: "Merge branch 'master' into dap_test_clie..." | Re-trigger Greptile

Comment thread uni/udb/test_adapter.icn Resolved
Comment thread uni/udb/test_adapter.icn Resolved
Comment thread uni/udb/Makefile Resolved
@JosephAbdo

Copy link
Copy Markdown
Contributor Author

@greptile review

@Jafaral Jafaral left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use some refactoring just simplify the code a bit.

Comment thread uni/udb/test_adapter.icn Resolved
Comment thread uni/udb/test_adapter.icn Resolved
Comment thread uni/udb/test_adapter.icn Resolved
Comment thread uni/udb/test_adapter.icn Resolved
Comment thread uni/udb/test_adapter.icn Resolved
Comment thread uni/udb/test_adapter.icn Resolved
@JosephAbdo

Copy link
Copy Markdown
Contributor Author

@greptile review

Comment thread uni/udb/adapter.icn Resolved

@Jafaral Jafaral left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing the issues found in the review!

Comment thread uni/udb/adapter.icn Resolved
Comment thread uni/udb/adapter.icn Resolved

@Jafaral Jafaral left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It maybe easier if we leave all other tests alone in this PR. Mixing all udb changes with all tests changes is hard to follow., especially with all of the change churns form one commit to the next. So, let us focus one one task here. The PR says add a DAP test client, let us keep it at that.

@JosephAbdo
JosephAbdo force-pushed the dap_test_client branch 4 times, most recently from 56217d6 to 9da6342 Compare April 29, 2026 23:11
Signed-off-by: Joseph Abdo <[email protected]>
Expand the adapter test client to cover breakpoints, stack traces, scopes, variables, evaluation, and stepping requests.

Signed-off-by: Joseph Abdo <[email protected]>
Signed-off-by: Joseph Abdo <[email protected]>
Move the adapter test into tests/udb and integrate it with the automated UDB test suite.

Update the UDB suite Makefile to build and run the adapter test.

Align the UDB suite output with other test suites by standardizing result formatting and integrating it into the top-level summary.

Signed-off-by: Joseph Abdo <[email protected]>
Signed-off-by: Joseph Abdo <[email protected]>
@JosephAbdo
JosephAbdo force-pushed the dap_test_client branch 9 times, most recently from 1398210 to c90aeff Compare May 4, 2026 15:21
@github-actions github-actions Bot added the ci label May 4, 2026
@JosephAbdo
JosephAbdo force-pushed the dap_test_client branch 3 times, most recently from 43628d4 to 2587a65 Compare May 7, 2026 03:48

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants