forked from tarantool/tarantool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The tarantool#8350 was introduced by the commit b42302f ("lua-yaml: enable aliasing for objects returned by __serialize") so the patch is effectively reversed. The idea is to call all object __serialize methods recursively before finding references. In the process we need to keep an eye on reference structure of course. Closes tarantool#8350 Closes tarantool#8321 Closes tarantool#8310 NO_DOC=bugfix
- Loading branch information
Showing
49 changed files
with
1,439 additions
and
1,299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## bugfix/lua | ||
|
||
* Fixed yaml alias serialization (gh-8350, gh-8321, gh-8310). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
local yaml = require('yaml') | ||
local fiber = require('fiber') | ||
local t = require('luatest') | ||
|
||
local g = t.group() | ||
|
||
local strip = function(str) | ||
return str:gsub('^%s*', ''):gsub('\n%s*', '\n') | ||
end | ||
|
||
local function serialize(o) | ||
return yaml.decode(yaml.encode(o)) | ||
end | ||
|
||
g.test_gh_8350_no_unnecessary_anchors = function() | ||
local x = {{}} | ||
setmetatable(x, {__serialize = function(t) return {x[1]} end}) | ||
local expected = [[ | ||
--- | ||
- [] | ||
... | ||
]] | ||
t.assert_equals(yaml.encode(x), strip(expected)) | ||
end | ||
|
||
g.test_gh_8310_alias_across_serialize_method = function() | ||
local x = {} | ||
local y = setmetatable({}, {__serialize = function() return x end}) | ||
local z = {x, y} | ||
local expected = [[ | ||
--- | ||
- &0 [] | ||
- *0 | ||
... | ||
]] | ||
t.assert_equals(yaml.encode(z), strip(expected)) | ||
end | ||
|
||
g.test_gh_8321_alias_between_same_udata_objects = function() | ||
local x = serialize({fiber.self(), fiber.self()}) | ||
t.assert(x[1] == x[2]) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.