git-codereview: fix test compilation error on Go 1.8
These tests depended on Go 1.9's t.Helper.
Change-Id: Ib8196e24f8508b4b2891cd1467dd9954bc5d8de5
Reviewed-on: https://go-review.googlesource.com/77932
Reviewed-by: Dominik Honnef <dominik@honnef.co>
diff --git a/git-codereview/go19_test.go b/git-codereview/go19_test.go
new file mode 100644
index 0000000..784ec41
--- /dev/null
+++ b/git-codereview/go19_test.go
@@ -0,0 +1,13 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build go1.9
+
+package main
+
+import "testing"
+
+func init() {
+ setHelper = func(t *testing.T) { t.Helper() }
+}
diff --git a/git-codereview/pending_test.go b/git-codereview/pending_test.go
index e29d0eb..025fb5b 100644
--- a/git-codereview/pending_test.go
+++ b/git-codereview/pending_test.go
@@ -14,6 +14,9 @@
"testing"
)
+// setHelper calls t.Helper() for Go 1.9+ (see go19_test.go) and does nothing otherwise.
+var setHelper = func(t *testing.T) {}
+
func TestPendingNone(t *testing.T) {
gt := newGitTest(t)
defer gt.done()
@@ -496,12 +499,12 @@
}
func testPending(t *testing.T, want string) {
- t.Helper()
+ setHelper(t)
testPendingArgs(t, nil, want)
}
func testPendingArgs(t *testing.T, args []string, want string) {
- t.Helper()
+ setHelper(t)
// fake auth information to avoid Gerrit error
if auth.host == "" {
auth.host = "gerrit.fake"