git-codereview: print git version when test fails to execute command
Sample output when modifying one of the git commands:
--- FAIL: TestSync (0.36s)
util_test.go:250: git-codereview change work
util_test.go:250: git-codereview sync
util_test.go:207: in git-client/, ran [git add --does-not-exist file1] with git version 1.9.1:
exit status 129
error: unknown option `does-not-exist'
usage: git add [options] [--] <pathspec>...
-n, --dry-run dry run
-v, --verbose be verbose
-i, --interactive interactive picking
-p, --patch select hunks interactively
-e, --edit edit current diff and apply
-f, --force allow adding otherwise ignored files
-u, --update update tracked files
-N, --intent-to-add record only the fact that the path will be added later
-A, --all add changes from all tracked and untracked files
--ignore-removal ignore paths removed in the working tree (same as --no-all)
--refresh don't add, only refresh the index
--ignore-errors just skip files which cannot be added because of errors
--ignore-missing check if - even missing - files are ignored in dry run
Updates golang/go#9602.
Change-Id: Ibeb93b1f3f4da43d1f95fd0eb5f2c372210cd6b3
Reviewed-on: https://go-review.googlesource.com/9952
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Andrew Gerrand <adg@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/git-codereview/util_test.go b/git-codereview/util_test.go
index a0ff469..f3d06df 100644
--- a/git-codereview/util_test.go
+++ b/git-codereview/util_test.go
@@ -20,6 +20,8 @@
"testing"
)
+var gitversion = "unknown git version" // git version for error logs
+
type gitTest struct {
pwd string // current directory before test
tmpdir string // temporary directory holding repos
@@ -123,6 +125,8 @@
}
}()
+ gitversion = trun(t, tmpdir, "git", "--version")
+
server := tmpdir + "/git-origin"
mkdir(t, server)
@@ -227,6 +231,9 @@
cmd.Dir = dir
out, err := cmd.CombinedOutput()
if err != nil {
+ if cmdline[0] == "git" {
+ t.Fatalf("in %s/, ran %s with %s:\n%v\n%s", filepath.Base(dir), cmdline, gitversion, err, out)
+ }
t.Fatalf("in %s/, ran %s: %v\n%s", filepath.Base(dir), cmdline, err, out)
}
return string(out)