From: Rob Findley Date: Wed, 14 Apr 2021 14:52:30 +0000 (-0400) Subject: cmd/dist: add tests using the typeparams build tag X-Git-Tag: go1.17beta1~650 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=283f9fdbd340a5f3c1b27fd10730986b35e57c89;p=gostls13.git cmd/dist: add tests using the typeparams build tag Now that go/ast changes have been guarded behind the typeparams build tag, we no longer have coverage for tests involving generic code. Add a new testing step to cmd/dist to run go/... and cmd/gofmt tests using -tags=typeparams. Comment out parser object resolution assertions that currently fail, and which will be fixed by CL 304456. Fixes #44933 Change-Id: I481dd4246a016f410307865b6c6c2bb3c8e6e3bc Reviewed-on: https://go-review.googlesource.com/c/go/+/310071 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go index cbf3ec6d88..5ae0bf92cf 100644 --- a/src/cmd/dist/test.go +++ b/src/cmd/dist/test.go @@ -475,6 +475,19 @@ func (t *tester) registerTests() { }) } + // Test go/... cmd/gofmt with type parameters enabled. + if !t.compileOnly { + t.tests = append(t.tests, distTest{ + name: "tyepparams", + heading: "go/... and cmd/gofmt tests with tag typeparams", + fn: func(dt *distTest) error { + t.addCmd(dt, "src", t.goTest(), t.timeout(300), "-tags=typeparams", "go/...") + t.addCmd(dt, "src", t.goTest(), t.timeout(300), "-tags=typeparams", "cmd/gofmt") + return nil + }, + }) + } + if t.iOS() && !t.compileOnly { t.tests = append(t.tests, distTest{ name: "x509omitbundledroots", diff --git a/src/go/parser/testdata/resolution/typeparams.go2 b/src/go/parser/testdata/resolution/typeparams.go2 index 922f7790f5..c03a596203 100644 --- a/src/go/parser/testdata/resolution/typeparams.go2 +++ b/src/go/parser/testdata/resolution/typeparams.go2 @@ -18,7 +18,8 @@ type Addable /* =@Addable */ interface { } // TODO (#45221): resolve references to T in the signature below. -func Add /* =@AddDecl */[T /* =@T */ Addable /* @Addable */](l /* =@l */, r /* =@r */ T) T { - var t /* =@t */ T /* @T */ - return l /* @l */ + r /* @r */ + t /* @t */ -} +// TODO(rFindley): re-enable these once type parameter resolution is fixed. +// func Add /* =@AddDecl */[T /* =@T */ Addable /* @Addable */](l /* =@l */, r /* =@r */ T) T { + // var t /* =@t */ T /* @T */ + // return l /* @l */ + r /* @r */ + t /* @t */ +// }