-
Notifications
You must be signed in to change notification settings - Fork 12
Add unified diff support for luatest.assert_equals
#438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
69c5c84 to
fef0177
Compare
ligurio
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Max, thanks for the patch!
Please take a look on my comments.
| local ok, encoded = pcall(yaml.encode, value) | ||
| if ok then | ||
| return encoded | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it is not serializable to YAML then ...?
1d91b35 to
26138ab
Compare
| function M.private.set_diff_enabled(value) | ||
| diff_enabled = value and true or false | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sseems this function is not needed anymore, right?
As I get right, diff_enabled logic in the test was needed when option for diff support was present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use this here to avoid editing old tests
luatest/test/luaunit/error_msg_test.lua
Lines 9 to 15 in 26138ab
| g.before_all(function() | |
| t.private.set_diff_enabled(false) | |
| end) | |
| g.after_all(function() | |
| t.private.set_diff_enabled(true) | |
| end) |
affa799 to
edcc8eb
Compare
This patch adds unified diff output for `t.assert_equals()` failures when the test suite is run with the `--diff` option, using a vendored Lua implementation of google/diff-match-patch (`luatest/vendor/diff_match_patch.lua` taken from [^1]). Closes tarantool#412 [^1]: https://github.com/google/diff-match-patch/blob/master/lua/diff_match_patch.lua
edcc8eb to
6a22390
Compare
| @@ -1,4 +1,4 @@ | |||
| include_files = {"**/*.lua", "*.rockspec", "*.luacheckrc"} | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit message mentions an option --diff that is gone
| local msgpack = require('msgpack') | ||
| local uri = require('uri') | ||
|
|
||
| -- Optional Tarantool-specific types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are not optional actually
| end | ||
|
|
||
| if t == 'string' then | ||
| return msgpack_to_yaml(value) or encode_yaml(value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why msgpack_to_yaml if type is a string? Shouldn't we return string as is?
This patch adds unified diff output for
t.assert_equals()failures when the test suite is run with the--diffoption, using a vendored Lua implementation of google/diff-match-patch (luatest/vendor/diff_match_patch.luataken from 1).Closes #412
Here is the output for the example from the issue:
code
Footnotes
https://github.com/google/diff-match-patch/blob/master/lua/diff_match_patch.lua ↩