Skip to content

Commit 00e5e28

Browse files
committed
testscript: remove "large files differ" diff size limit
Now that we no longer have to worry about pkg/diff's quadratic space memory usage, we can remove this limitation. Note that big_diff now includes the relatively big diff, but having the file go from two thousand lines to four thousand lines seems reasonable enough, and keeps the test script simple. I intended to do this as part of the previous commit, but clearly forgot to do this last piece.
1 parent 50a1440 commit 00e5e28

File tree

2 files changed

+2058
-11
lines changed

2 files changed

+2058
-11
lines changed

testscript/cmd.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,6 @@ func (ts *TestScript) doCmdCmp(neg bool, args []string, env bool) {
141141
// update the script.
142142
}
143143

144-
// pkg/diff is quadratic at the moment.
145-
// If the product of the number of lines in the inputs is too large,
146-
// don't call pkg.Diff at all as it might take tons of memory or time.
147-
// We found one million to be reasonable for an average laptop.
148-
const maxLineDiff = 1_000_000
149-
if strings.Count(text1, "\n")*strings.Count(text2, "\n") > maxLineDiff {
150-
ts.Fatalf("large files %s and %s differ", name1, name2)
151-
return
152-
}
153-
154144
unifiedDiff := diff.Diff(name1, []byte(text1), name2, []byte(text2))
155145

156146
ts.Logf("%s", unifiedDiff)

0 commit comments

Comments
 (0)