Skip to content
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

testscript: remove "large files differ" diff size limit #206

Merged
merged 1 commit into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 0 additions & 10 deletions testscript/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,6 @@ func (ts *TestScript) doCmdCmp(neg bool, args []string, env bool) {
// update the script.
}

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

unifiedDiff := diff.Diff(name1, []byte(text1), name2, []byte(text2))

ts.Logf("%s", unifiedDiff)
Expand Down