Skip to content

Commit

Permalink
Fixing a lua debugger bug that prevented use of 'server' for server.c…
Browse files Browse the repository at this point in the history
…all invocations. (#303)

* Tested it on local instance. This was originally part of
#288 but I am pushing this
separately, so that we can easily merge it into the upcoming release.

```
lua debugger> server ping
<redis> ping
<reply> "+PONG"
lua debugger> redis ping
<redis> ping
<reply> "+PONG"
```

* I also searched for lua debugger related unit tests to add coverage
for this but did not find any relevant test to modify. Leaving it at
that for now.

---------

Signed-off-by: Parth Patel <661497+parthpatel@users.noreply.github.com>
  • Loading branch information
parthpatel committed Apr 11, 2024
1 parent 3d887df commit 644692d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/eval.c
Expand Up @@ -1677,7 +1677,7 @@ ldbLog(sdsnew(" next line of code."));
luaPushError(lua, "script aborted for user request");
luaError(lua);
} else if (argc > 1 &&
(!strcasecmp(argv[0],"r") || !strcasecmp(argv[0],"redis"))) {
(!strcasecmp(argv[0],"r") || !strcasecmp(argv[0],REDIS_API_NAME) || !strcasecmp(argv[0],SERVER_API_NAME))) {
ldbRedis(lua,argv,argc);
ldbSendLogs();
} else if ((!strcasecmp(argv[0],"p") || !strcasecmp(argv[0],"print"))) {
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/scripting.tcl
Expand Up @@ -1547,6 +1547,19 @@ start_server {tags {"scripting needs:debug external:skip"}} {
reconnect
assert_equal [r ping] {PONG}
}

test {Test scripting debug lua server invocations} {
r script debug sync
r eval {return 'hello'} 0
set cmd "*2\r\n\$6\r\nserver\r\n\$4\r\nping\r\n"
r write $cmd
r flush
set ret [r read]
puts $ret
assert_match {*PONG*} $ret
reconnect
assert_equal [r ping] {PONG}
}
}

start_server {tags {"scripting external:skip"}} {
Expand Down

0 comments on commit 644692d

Please sign in to comment.