From bc3cf281b174140db33ad4dc78a985e1e8770a7f Mon Sep 17 00:00:00 2001 From: Rob Findley Date: Wed, 4 Nov 2020 18:45:44 -0500 Subject: [PATCH] go/loader: loosen a test assertion on go/types error messages In CL 267717, the error message for invalid assignment of untyped values is being corrected from 'cannot convert ...' to 'cannot use ... as ... int ...'. This breaks the go/loader tests due to an assertion on the former message. Since the Go repo TryBots run x/tools tests, this assertion must be loosened to allow merging the CL above. Change-Id: I8a371397c9df58109090b7fd2eaa5b4a600776ef Reviewed-on: https://go-review.googlesource.com/c/tools/+/267686 Run-TryBot: Robert Findley Trust: Robert Findley Trust: Robert Griesemer gopls-CI: kokoro TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- go/loader/loader_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/go/loader/loader_test.go b/go/loader/loader_test.go index 5fa3254674..e68405ad0c 100644 --- a/go/loader/loader_test.go +++ b/go/loader/loader_test.go @@ -645,8 +645,11 @@ func TestErrorReporting(t *testing.T) { for pkg, info := range prog.AllPackages { switch pkg.Path() { case "a": - if !hasError(info.Errors, "cannot convert false") { - t.Errorf("a.Errors = %v, want bool conversion (type) error", info.Errors) + // The match below is unfortunately vague, because in go1.16 the error + // message in go/types changed from "cannot convert ..." to "cannot use + // ... as ... in assignment". + if !hasError(info.Errors, "cannot") { + t.Errorf("a.Errors = %v, want bool assignment (type) error", info.Errors) } if !hasError(info.Errors, "could not import c") { t.Errorf("a.Errors = %v, want import (loader) error", info.Errors) @@ -659,7 +662,7 @@ func TestErrorReporting(t *testing.T) { } // Check errors reported via error handler. - if !hasError(allErrors, "cannot convert false") || + if !hasError(allErrors, "cannot") || !hasError(allErrors, "rune literal not terminated") || !hasError(allErrors, "could not import c") { t.Errorf("allErrors = %v, want syntax, type and loader errors", allErrors)