Skip to content

Commit

Permalink
exec: support sparse input
Browse files Browse the repository at this point in the history
After previous commit, `:exec` support sparse output, but not sparse
args. It seems like a good idea to support it too, since it's too easy
now.

Follows #350
  • Loading branch information
DifferentialOrange committed Jan 19, 2024
1 parent ca81a95 commit ea2cc8d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Fixed incorrent unix socket path length check (gh-341).
* Now net_box_uri can be accepted as table (gh-342).
* Fixed returning values from `Server:exec()` if some of them are nil (gh-350).
* Support `nil` args for `Server:exec()`.

## 1.0.0

Expand Down
2 changes: 1 addition & 1 deletion luatest/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ function Server:exec(fn, args, options)
if args == nil then
result = {pcall(fn)}
else
result = {pcall(fn, unpack(args))}
result = {pcall(fn, unpack_sparse_array(args))}
end
if not result[1] then
if type(result[2]) == 'table' then
Expand Down
7 changes: 7 additions & 0 deletions test/autorequire_luatest_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,10 @@ g.test_exec_with_sparse_output = function()
t.assert_equals(res1, nil)
t.assert_equals(res2, 'some error')
end

g.test_exec_with_sparse_input = function()
g.server:exec(function(v1, v2)
t.assert_equals(v1, nil)
t.assert_equals(v2, 'val')
end, {nil, 'val'})
end

0 comments on commit ea2cc8d

Please sign in to comment.