stretchr/testify

Diff is empty when lines are too long

Open

#746 geöffnet am 27. März 2019

Auf GitHub ansehen
 (6 Kommentare) (7 Reaktionen) (0 zugewiesene Personen)Go (1.704 Forks)batch import
help wanted

Repository-Metriken

Stars
 (25.958 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 15h) (2 gemergte PRs in 30 T)

Beschreibung

On assert.Equal failures, if the diff has long lines (due to complicated structs), instead of showing something like

require.go:157:
                	Error Trace:	common_test.go:72
                	            				transactions_test.go:844
                	Error:      	Not equal:
					expected: ...
					actual: ...

					Diff:
					--- Expected
					+++ Actual
					<super long line...>
                	Test:       	TestTransactionsQueryFingerprint
                	Messages:   	Response does not match expected return

Currently the diff is completely cut off

require.go:157:
                	Error Trace:	common_test.go:72
                	            				transactions_test.go:844
                	Error:      	Not equal:
                	Test:       	TestTransactionsQueryFingerprint
                	Messages:   	Response does not match expected return

This makes testing hard to check which lines differed.

Upon inspecting, indentation formatting of diff lines is using bufio.Scanner which has a default MaxScanTokenSize (64K) and would not parse long lines: https://github.com/stretchr/testify/blob/master/assert/assertions.go#L201

Can be fixed by either changing from bufio.Scanner to bufio.Reader or truncating long lines up to the max token size (or even provide a config to change max). Thoughts?

Contributor Guide