From: Robert Griesemer Date: Thu, 17 Mar 2022 21:04:37 +0000 (-0700) Subject: go/types, types2: use new flag mechanims to handle importC test X-Git-Tag: go1.19beta1~975 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=101d14e3b315e6990f02bef2044a7021a9ca9ea0;p=gostls13.git go/types, types2: use new flag mechanims to handle importC test Change-Id: I6f0cb850ee23184380c03a53c12425c350aa16e3 Reviewed-on: https://go-review.googlesource.com/c/go/+/393714 Trust: Robert Griesemer Reviewed-by: Robert Findley --- diff --git a/src/cmd/compile/internal/types2/check_test.go b/src/cmd/compile/internal/types2/check_test.go index 89d2cc644c..988983ee04 100644 --- a/src/cmd/compile/internal/types2/check_test.go +++ b/src/cmd/compile/internal/types2/check_test.go @@ -130,6 +130,7 @@ func testFiles(t *testing.T, filenames []string, colDelta uint, manual bool) { var conf Config flags := flag.NewFlagSet("", flag.PanicOnError) flags.StringVar(&conf.GoVersion, "lang", "", "") + flags.BoolVar(&conf.FakeImportC, "fakeImportC", false, "") if err := parseFlags(filenames[0], nil, flags); err != nil { t.Fatal(err) } @@ -156,10 +157,6 @@ func testFiles(t *testing.T, filenames []string, colDelta uint, manual bool) { } // typecheck and collect typechecker errors - // special case for importC.src - if len(filenames) == 1 && strings.HasSuffix(filenames[0], "importC.src") { - conf.FakeImportC = true - } conf.Trace = manual && testing.Verbose() conf.Importer = defaultImporter() conf.Error = func(err error) { diff --git a/src/cmd/compile/internal/types2/testdata/check/importC.src b/src/cmd/compile/internal/types2/testdata/check/importC.src index f55be2d5c5..807802199f 100644 --- a/src/cmd/compile/internal/types2/testdata/check/importC.src +++ b/src/cmd/compile/internal/types2/testdata/check/importC.src @@ -1,3 +1,5 @@ +// -fakeImportC + // Copyright 2015 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. diff --git a/src/go/types/check_test.go b/src/go/types/check_test.go index 6bee41d141..d962b0c405 100644 --- a/src/go/types/check_test.go +++ b/src/go/types/check_test.go @@ -233,6 +233,7 @@ func testFiles(t *testing.T, sizes Sizes, filenames []string, srcs [][]byte, man conf.Sizes = sizes flags := flag.NewFlagSet("", flag.PanicOnError) flags.StringVar(&conf.GoVersion, "lang", "", "") + flags.BoolVar(&conf.FakeImportC, "fakeImportC", false, "") if err := parseFlags(filenames[0], srcs[0], flags); err != nil { t.Fatal(err) } @@ -265,17 +266,10 @@ func testFiles(t *testing.T, sizes Sizes, filenames []string, srcs [][]byte, man } // typecheck and collect typechecker errors - // special case for importC.src - if len(filenames) == 1 { - if strings.HasSuffix(filenames[0], "importC.src") { - conf.FakeImportC = true - } - } - - conf.Importer = imp if imp == nil { - conf.Importer = importer.Default() + imp = importer.Default() } + conf.Importer = imp conf.Error = func(err error) { if *haltOnError { defer panic(err) diff --git a/src/go/types/testdata/check/importC.src b/src/go/types/testdata/check/importC.src index f55be2d5c5..807802199f 100644 --- a/src/go/types/testdata/check/importC.src +++ b/src/go/types/testdata/check/importC.src @@ -1,3 +1,5 @@ +// -fakeImportC + // Copyright 2015 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.