Skip to content

Commit

Permalink
Removed unused test code
Browse files Browse the repository at this point in the history
  • Loading branch information
Nimaoth committed Aug 31, 2024
1 parent a2b7117 commit 476f403
Showing 1 changed file with 0 additions and 127 deletions.
127 changes: 0 additions & 127 deletions src/text/language/dap_client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -812,130 +812,3 @@ proc run*(client: DAPClient) =
# logServerDebug = val

# addActiveDispatchTable "dap", genDispatchTable("dap"), global=true

when isMainModule:
import std/[sugar, parseopt]
logger.enableConsoleLogger()

var port = -1

var optParser = initOptParser("")
for kind, key, val in optParser.getopt():
case kind
of cmdArgument:
discard

of cmdLongOption, cmdShortOption:
case key
of "port", "p":
port = val.parseInt

else:
discard

proc test() {.async.} =

when defined(windows):
const lldpDapPath = "D:/llvm/bin/lldb-dap.exe"
# const lldpDapPath = "lldb-dap.exe"
else:
const lldpDapPath = "/bin/lldb-dap-18"
# const lldpDapPath = "/home/nimaoth/dev/llvm-project/build_lldb/bin/lldb-dap"

var connection: Connection
if port >= 0:
connection = await newAsyncSocketConnection("127.0.0.1", port.Port)
else:
connection = await newAsyncProcessConnection(lldpDapPath, @[])

var client = newDAPClient(connection)

discard client.onInitialized.subscribe (data: OnInitializedData) =>
log(lvlInfo, &"onInitialized")
discard client.onStopped.subscribe (data: OnStoppedData) =>
log(lvlInfo, &"onStopped {data}")
discard client.onContinued.subscribe (data: OnContinuedData) =>
log(lvlInfo, &"onContinued {data}")
discard client.onExited.subscribe (data: OnExitedData) =>
log(lvlInfo, &"onExited {data}")
discard client.onTerminated.subscribe (data: Option[OnTerminatedData]) =>
log(lvlInfo, &"onTerminated {data}")
discard client.onThread.subscribe (data: OnThreadData) =>
log(lvlInfo, &"onThread {data}")
discard client.onOutput.subscribe (data: OnOutputData) =>
log(lvlInfo, &"[dap-{data.category}] {data.output}")
discard client.onBreakpoint.subscribe (data: OnBreakpointData) =>
log(lvlInfo, &"onBreakpoint {data}")
discard client.onModule.subscribe (data: OnModuleData) =>
log(lvlInfo, &"onModule {data}")
discard client.onLoadedSource.subscribe (data: OnLoadedSourceData) =>
log(lvlInfo, &"onLoadedSource {data}")
discard client.onProcess.subscribe (data: OnProcessData) =>
log(lvlInfo, &"onProcess {data}")
discard client.onCapabilities.subscribe (data: OnCapabilitiesData) =>
log(lvlInfo, &"onCapabilities {data}")
discard client.onProgressStart.subscribe (data: OnProgressStartData) =>
log(lvlInfo, &"onProgressStart {data}")
discard client.onProgressUpdate.subscribe (data: OnProgressUpdateData) =>
log(lvlInfo, &"onProgressUpdate {data}")
discard client.onProgressEnd.subscribe (data: OnProgressEndData) =>
log(lvlInfo, &"onProgressEnd {data}")
discard client.onInvalidated.subscribe (data: OnInvalidatedData) =>
log(lvlInfo, &"onInvalidated {data}")
discard client.onMemory.subscribe (data: OnMemoryData) =>
log(lvlInfo, &"onMemory {data}")

await client.initialize()

when defined(linux):
let sourcePath = "/mnt/c/Absytree/temp/test.cpp"
let exePath = "/mnt/c/Absytree/temp/test_dbg"
# let sourcePath = "/mnt/c/Absytree/temp/test.py"
# let exePath = "/mnt/c/Absytree/temp/test.py"
else:
let sourcePath = "C:\\Absytree\\temp\\test.cpp"
let exePath = "C:\\Absytree\\temp\\test_dbg.exe"

if client.waitInitialized.await:
# await client.attach %*{
# "program": exePath,
# }

await client.launch %*{
"program": exePath,
}

let threads = await client.getThreads
if threads.isError:
log lvlError, &"Failed to get threads: {threads}"
return

debugf"waiting for initialized event"
await client.waitInitializedEventReceived

await client.setBreakpoints(
Source(path: sourcePath.some),
@[
SourceBreakpoint(line: 42),
SourceBreakpoint(line: 52),
]
)

await client.configurationDone()

await sleepAsync(2000)

let stackTrace = await client.stackTrace(threads.result.threads[0].id)
debugf"stacktrace: {stackTrace}"

await client.continueExecution(threads.result.threads[0].id)
await sleepAsync(1000)
await client.next(threads.result.threads[0].id)

await sleepAsync(2000)
await client.disconnect(restart=false)

try:
waitFor test()
except ValueError:
discard

0 comments on commit 476f403

Please sign in to comment.