stretchr/testify

Diff is empty when lines are too long

Open

#746 创建于 2019年3月27日

在 GitHub 查看
 (6 评论) (7 反应) (0 负责人)Go (25,958 star) (1,704 fork)batch import
help wanted

描述

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?

贡献者指南