Support function load command
This commit is contained in:
parent
758ac48278
commit
0e87c6f79c
13
cts.json
13
cts.json
|
@ -5314,5 +5314,18 @@
|
||||||
"True"
|
"True"
|
||||||
],
|
],
|
||||||
"since": "2.2.0"
|
"since": "2.2.0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "function load command",
|
||||||
|
"command": [
|
||||||
|
"function flush",
|
||||||
|
"function load \"#!lua name=mylib \n redis.register_function('myfunc', function(keys, args) return args[1] end)\""
|
||||||
|
],
|
||||||
|
"result": [
|
||||||
|
"OK",
|
||||||
|
"mylib"
|
||||||
|
],
|
||||||
|
"since": "7.0.0",
|
||||||
|
"command_split": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -130,6 +130,23 @@ def trans_cmd(test, cmd):
|
||||||
array.append(ord(cmd[i]))
|
array.append(ord(cmd[i]))
|
||||||
i += 1
|
i += 1
|
||||||
return bytes(array)
|
return bytes(array)
|
||||||
|
elif 'command_split' in test:
|
||||||
|
# split command by ""
|
||||||
|
# input: 'hello "world of python" example'
|
||||||
|
# output: ['hello', 'world of python', 'example']
|
||||||
|
parts = []
|
||||||
|
in_quote = False
|
||||||
|
current_part = ''
|
||||||
|
for char in cmd:
|
||||||
|
if char == '"':
|
||||||
|
in_quote = not in_quote
|
||||||
|
elif char == ' ' and not in_quote:
|
||||||
|
parts.append(current_part)
|
||||||
|
current_part = ''
|
||||||
|
else:
|
||||||
|
current_part += char
|
||||||
|
parts.append(current_part)
|
||||||
|
return parts
|
||||||
else:
|
else:
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -156,7 +173,11 @@ def run_test(test):
|
||||||
trans_result_to_bytes(result)
|
trans_result_to_bytes(result)
|
||||||
try:
|
try:
|
||||||
for idx, cmd in enumerate(command):
|
for idx, cmd in enumerate(command):
|
||||||
ret = trans_result_to_bytes(r.execute_command(trans_cmd(test, cmd)))
|
tcmd = trans_cmd(test, cmd)
|
||||||
|
if (isinstance(tcmd, list)):
|
||||||
|
ret = trans_result_to_bytes(r.execute_command(*trans_cmd(test, cmd)))
|
||||||
|
else:
|
||||||
|
ret = trans_result_to_bytes(r.execute_command(trans_cmd(test, cmd)))
|
||||||
if result[idx] != ret:
|
if result[idx] != ret:
|
||||||
test_failed(g_results[since], name, f"expected: {result[idx]}, result: {ret}")
|
test_failed(g_results[since], name, f"expected: {result[idx]}, result: {ret}")
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue