Skip to content

Commit 2c6e03f

Browse files
committed
internal/testenv: allow Apple diff too
On recent versions of MacOS, tests in difftest and rename fail because HasTool doesn't like the default Apple diff. The comment (from 6 years ago) says that diff must support the -u flag, for unified output formatting) and report missing newlines at the end of files. The current Apple diff does this. (I do not know why this does not affect the builders.) Change-Id: I224a224eec1473e2a4bf3c947da77a8b3a623c9a Reviewed-on: https://go-review.googlesource.com/c/tools/+/719920 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Madeline Kalil <mkalil@google.com>
1 parent 82112c0 commit 2c6e03f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

internal/testenv/testenv.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,14 @@ func HasTool(tool string) error {
131131
}
132132

133133
case "diff":
134-
// Check that diff is the GNU version, needed for the -u argument and
134+
// Check that diff is the GNU or Apple version, needed for the -u argument and
135135
// to report missing newlines at the end of files.
136136
out, err := exec.Command(tool, "-version").Output()
137137
if err != nil {
138+
out, _ = exec.Command(tool, "--version").Output()
139+
if bytes.Contains(out, []byte("Apple diff")) {
140+
return nil
141+
}
138142
return err
139143
}
140144
if !bytes.Contains(out, []byte("GNU diffutils")) {

0 commit comments

Comments
 (0)