From fc492d2e106922eb3aa4bca863d55e882c087ae3 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 28 Nov 2017 02:37:14 +0000 Subject: [PATCH] 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 Reviewed-by: Tom Bergan TryBot-Result: Gobot Gobot --- http/httpproxy/go19_test.go | 13 +++++++++++++ http/httpproxy/proxy_test.go | 5 ++++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 http/httpproxy/go19_test.go diff --git a/http/httpproxy/go19_test.go b/http/httpproxy/go19_test.go new file mode 100644 index 00000000..2117ca56 --- /dev/null +++ b/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() } +} diff --git a/http/httpproxy/proxy_test.go b/http/httpproxy/proxy_test.go index f307964a..e4af199c 100644 --- a/http/httpproxy/proxy_test.go +++ b/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"