-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| include_files = {"**/*.lua", "*.rockspec", "*.luacheckrc"} | ||
| exclude_files = {"build.luarocks/", "lua_modules/", "tmp/", ".luarocks/", ".rocks/"} | ||
| exclude_files = {"build.luarocks/", "lua_modules/", "tmp/", ".luarocks/", ".rocks/", "luatest/vendor/"} | ||
|
|
||
| max_line_length = 120 | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |||||||||||||||
| local math = require('math') | ||||||||||||||||
|
|
||||||||||||||||
| local comparator = require('luatest.comparator') | ||||||||||||||||
| local diff = require('luatest.diff') | ||||||||||||||||
| local mismatch_formatter = require('luatest.mismatch_formatter') | ||||||||||||||||
| local pp = require('luatest.pp') | ||||||||||||||||
| local log = require('luatest.log') | ||||||||||||||||
|
|
@@ -20,12 +21,17 @@ local prettystr_pairs = pp.tostring_pair | |||||||||||||||
| local M = {} | ||||||||||||||||
|
|
||||||||||||||||
| local xfail = false | ||||||||||||||||
| local diff_enabled = true | ||||||||||||||||
|
|
||||||||||||||||
| local box_error_type = ffi.typeof(box.error.new(box.error.UNKNOWN)) | ||||||||||||||||
|
|
||||||||||||||||
| -- private exported functions (for testing) | ||||||||||||||||
| M.private = {} | ||||||||||||||||
|
|
||||||||||||||||
| function M.private.set_diff_enabled(value) | ||||||||||||||||
| diff_enabled = value and true or false | ||||||||||||||||
| end | ||||||||||||||||
|
Comment on lines
+31
to
+33
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sseems this function is not needed anymore, right?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||||||||||||||
|
|
||||||||||||||||
| function M.private.is_xfail() | ||||||||||||||||
| local xfail_status = xfail | ||||||||||||||||
| xfail = false | ||||||||||||||||
|
|
@@ -83,6 +89,14 @@ local function error_msg_equality(actual, expected, deep_analysis) | |||||||||||||||
| if success then | ||||||||||||||||
| result = table.concat({result, mismatchResult}, '\n') | ||||||||||||||||
| end | ||||||||||||||||
|
|
||||||||||||||||
| if diff_enabled then | ||||||||||||||||
| local diff_result = diff.build_unified_diff(expected, actual) | ||||||||||||||||
| if diff_result then | ||||||||||||||||
| result = table.concat({result, 'diff:', diff_result}, '\n') | ||||||||||||||||
| end | ||||||||||||||||
| end | ||||||||||||||||
|
|
||||||||||||||||
| return result | ||||||||||||||||
| end | ||||||||||||||||
| return string.format("expected: %s, actual: %s", | ||||||||||||||||
|
|
||||||||||||||||
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
--diffthat is gone