浏览代码

http/httpproxy: fix build on Go 1.8

Go 1.8 doesn't have t.Helper.

Fix the row of red on the dashboard.

Change-Id: I85d4bb9fe38e989dc3b6a4e99705599745b83cef
Reviewed-on: https://go-review.googlesource.com/80140
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Tom Bergan <tombergan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Brad Fitzpatrick 8 年之前
父节点
当前提交
fc492d2e10
共有 2 个文件被更改,包括 17 次插入1 次删除
  1. 13 0
      http/httpproxy/go19_test.go
  2. 4 1
      http/httpproxy/proxy_test.go

+ 13 - 0
http/httpproxy/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 httpproxy_test
+
+import "testing"
+
+func init() {
+	setHelper = func(t *testing.T) { t.Helper() }
+}

+ 4 - 1
http/httpproxy/proxy_test.go

@@ -16,6 +16,9 @@ import (
 	"golang.org/x/net/http/httpproxy"
 )
 
+// setHelper calls t.Helper() for Go 1.9+ (see go19_test.go) and does nothing otherwise.
+var setHelper = func(t *testing.T) {}
+
 type proxyForURLTest struct {
 	cfg     httpproxy.Config
 	req     string // URL to fetch; blank means "http://example.com"
@@ -166,7 +169,7 @@ var proxyForURLTests = []proxyForURLTest{{
 }}
 
 func testProxyForURL(t *testing.T, tt proxyForURLTest) {
-	t.Helper()
+	setHelper(t)
 	reqURLStr := tt.req
 	if reqURLStr == "" {
 		reqURLStr = "http://example.com"