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 <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Robert Griesemer 2022-03-17 14:04:37 -07:00
parent 3395f74d86
commit 101d14e3b3
4 changed files with 8 additions and 13 deletions

View File

@ -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) {

View File

@ -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.

View File

@ -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)

View File

@ -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.