Repository: jhump/protoreflect
Pull request #259 (2019-08-02 14:09:11)

Disable GOPROXY for gotip
This PR ensures that issue like #258 would fail at CI stage by disabling GOPROXY for gotip (Go 1.13).

jhump: Mind providing a TLDR on what these environment variables actually do?

Patch:
diff --git a/.travis.yml b/.travis.yml
index d52523c..5100d79 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -16,6 +16,8 @@ matrix:
     - go: "1.12"
       env: GO111MODULE=on
     - go: tip
+      env:
+      - GOPROXY=direct
 
 # accomodate forks
 before_install:
diff --git a/desc/protoparse/errors.go b/desc/protoparse/errors.go
index 9f3db90..a4063a8 100644
--- a/desc/protoparse/errors.go
+++ b/desc/protoparse/errors.go
@@ -58,9 +58,12 @@ func (h *errorHandler) getError() error {
 
 // ErrorWithPos is an error about a proto source file that includes information
 // about the location in the file that caused the error.
+//
+// The value of Error() will contain both the SourcePos and Underlying error.
 type ErrorWithPos interface {
 	error
 	GetPosition() SourcePos
+	GetUnderlying() error
 }
 
 // ErrorWithSourcePos is an error about a proto source file that includes
@@ -90,4 +93,10 @@ func (e ErrorWithSourcePos) GetPosition() SourcePos {
 	return *e.Pos
 }
 
+// GetUnderlying implements the ErrorWithPos interface, supplying the
+// underlying error. This error will not include location information.
+func (e ErrorWithSourcePos) GetUnderlying() error {
+	return e.Underlying
+}
+
 var _ ErrorWithPos = ErrorWithSourcePos{}
diff --git a/go.mod b/go.mod
index 2202828..816dd64 100644
--- a/go.mod
+++ b/go.mod
@@ -4,6 +4,6 @@ require (
 	github.com/golang/protobuf v1.3.1
 	golang.org/x/net v0.0.0-20180530234432-1e491301e022
 	golang.org/x/text v0.3.0 // indirect
-	google.golang.org/genproto v0.0.0-20170818100345-ee236bd376b0
+	google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0
 	google.golang.org/grpc v1.8.0
 )
diff --git a/go.sum b/go.sum
index 2a2f111..c1b8971 100644
--- a/go.sum
+++ b/go.sum
@@ -4,7 +4,7 @@ golang.org/x/net v0.0.0-20180530234432-1e491301e022 h1:MVYFTUmVD3/+ERcvRRI+P/C2+
 golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-google.golang.org/genproto v0.0.0-20170818100345-ee236bd376b0 h1:jgaHBfsPDMBDKsth1hPtI1HcOyecWndWOFSGW21VgaM=
-google.golang.org/genproto v0.0.0-20170818100345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
+google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0 h1:ZvI3lsq5AIkr7axxmT3tfwFlJVRFLqe6Fp0W03+MJ38=
+google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
 google.golang.org/grpc v1.8.0 h1:HN69LlNA/SpyBIRxTfuU0QOntYfdeEeBWlVhRHRCOyw=
 google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=


Test patch:
diff --git a/desc/protoparse/error_reporting_test.go b/desc/protoparse/error_reporting_test.go
index faa446e..1f298a5 100644
--- a/desc/protoparse/error_reporting_test.go
+++ b/desc/protoparse/error_reporting_test.go
@@ -190,7 +190,10 @@ func TestErrorReporting(t *testing.T) {
 		testutil.Eq(t, len(tc.expectedErrs), count, "case #%d: parse should have called reporter %d times", i+1, len(tc.expectedErrs))
 		testutil.Eq(t, len(tc.expectedErrs), len(reported), "case #%d: wrong number of errors reported", i+1)
 		for j := range tc.expectedErrs {
-			testutil.Require(t, strings.Contains(reported[j].Error(), tc.expectedErrs[j]), "case #%d: parse error[%d] have %q; instead got %q", i+1, j, tc.expectedErrs[j], reported[j].Error())
+			testutil.Eq(t, tc.expectedErrs[j], reported[j].Error(), "case #%d: parse error[%d] have %q; instead got %q", i+1, j, tc.expectedErrs[j], reported[j].Error())
+			split := strings.SplitN(tc.expectedErrs[j], ":", 4)
+			testutil.Eq(t, 4, len(split), "case #%d: expected %q [%d] to contain at least 4 elements split by :", i+1, tc.expectedErrs[j], j)
+			testutil.Eq(t, split[3], " "+reported[j].GetUnderlying().Error(), "case #%d: parse error underlying[%d] have %q; instead got %q", i+1, j, split[3], reported[j].GetUnderlying().Error())
 		}
 
 		count = 0