print the diff between right result and wrong result#141
Merged
Conversation
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Defined2014
approved these changes
Dec 4, 2025
D3Hunter
approved these changes
Dec 4, 2025
lance6716
reviewed
Dec 4, 2025
|
|
||
| func (e *WrongResultError) Error() string { | ||
| diff := diffmatchpatch.New() | ||
| diffText := diff.DiffPrettyText(diff.DiffMain(e.actual, e.expected, false)) |
There was a problem hiding this comment.
what's the effect of checklines = false?
Member
Author
There was a problem hiding this comment.
Actually, I gave it a try, but I couldn't see any difference.
There was a problem hiding this comment.
Copilot:
In sergi/go-diff, the checklines parameter controls whether the diff algorithm first does a fast, line‑level diff before falling back to a more precise, character‑level diff.
Specifically:
DiffMain(text1, text2, checklines bool)passeschecklinesdown todiffCompute:func (dmp *DiffMatchPatch) diffCompute(text1, text2 []rune, checklines bool, deadline time.Time) []Diff { … } else if checklines && len(text1) > 100 && len(text2) > 100 { return dmp.diffLineMode(text1, text2, deadline) } return dmp.diffBisect(text1, text2, deadline) }
- When
checklines == trueand both texts are longer than 100 runes, it usesdiffLineMode, which:- Does a quick diff at line granularity (treating each line as a token), then
- “Rediffs” the changed line blocks at character level for better accuracy.
Effects in practice
-
checklines = false- Always uses
diffBisect(a Myers-style character-level diff). - Slower on large inputs, but tends to give minimal/optimal character-level diffs.
- Always uses
-
checklines = true- For long texts: runs the faster line-mode pre-pass, then refines.
- This usually gives a significant speedup on big inputs, at the cost of possibly non-minimal diffs (more or differently grouped hunks than the theoretical minimum).
The tests (TestDiffMainWithCheckLines) confirm that:
- For most cases, results with and without
checklinesmatch exactly. - It’s explicitly documented that the speedup “can produce non-minimal diffs” (comment on
diffLineMode), and there’s a TODO about a failing test case, highlighting that behavior can differ.
dveeden
pushed a commit
to dveeden/mysql-tester
that referenced
this pull request
May 22, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When your result set changes significantly, it's not easy to directly discern the differences from the logs. I've modified the log format so that it can print the diff.
before
after the improvement